Accessing SQL Server 2005 from web service

Discussion in 'ASP.NET WebServices' started by chris1, Apr 30, 2008.

  1. Dear All,

    I have a test web service installed and working fine even though it only returns 'Hello World'.

    I now want to access my SQL server 2005 database's on asp.net via the web service. Does anyone have any sample vb.net or c# code to do this

    Many Thanks

    Chris Anderson
     
  2. Bruce

    Bruce DiscountASP.NET Staff

  3. Bruce

    Bruce DiscountASP.NET Staff

    if you are using the test code in the KB, you probably didn't put in this line (make sure you replace the select statement.)

    dbCMD = new sqlcommand ("select * from tblTest",dbconn)



    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  4. Bruce,

    Many thanks, testing that out today


    Regards

    Chris Anderson
     
  5. Bruce,


    Ive tried the code. At the line:





    dtr = dbCMD.ExecuteReader()

    I get an error: (using catch ex as exception):


    ExecuteReader: command text property has not been initialised

    Any ideas please ?


    Regards

    Chris Anderson
     

Share This Page