Error while connecting to db?

  • Thread starter shaila th via .NET 247
  • Start date
S

shaila th via .NET 247

(Type your message here)

--------------------------------
From: shaila th

I have created a .NET Web service project. I'm trying to connect to a SQL Server database from my webservice.
I downloaded the Data Access Application block for accessing data from sqlserver db.
The sql statement alone works fine, I have tested it.
I get a "Page cannot be displayed error" while invoking this method.
Can anyone let me know why I'm getting this problem...?
Here is my code:


[WebMethod]
public DataSet CreateTest()
{
//Establish connection to SQLServer database
SqlConnection conn = new SqlConnection("Server=xxxxx;User=xxxxx;Database=xxxxx");
//I'll be calling a Stored Procedure instead of this sql statement
SqlDataAdapter adapter1 = new SqlDataAdapter("INSERT INTO test (test_type,test_desc,test_date,owner_name,owner_account,test_name,cust_name,cust_phone,cust_fax,test_status) values ('x','x','04-20-2004','x', 'x', 'x', 'x', '0000','0000', 'Accepted')",conn);
//Open the database connection
DataSet ds1 = new DataSet();
// Open the database connection
conn.Open();
adapter1.Fill(ds1,"tests");
// Close db connection
conn.Close();
return ds1;
}
 
J

Jan Tielens

Can you display the complete exception message?

(Maybe you have to turn off "user friendly" error messages in IE to be able
to view it.)

--
Greetz,
Jan
________________________
Read my weblog: http://weblogs.asp.net/jan

shaila th via .NET 247 said:
(Type your message here)
Server database from my webservice.
I downloaded the Data Access Application block for accessing data from sqlserver db.
The sql statement alone works fine, I have tested it.
I get a "Page cannot be displayed error" while invoking this method.
Can anyone let me know why I'm getting this problem...?
Here is my code:


[WebMethod]
public DataSet CreateTest()
{
//Establish connection to SQLServer database
SqlConnection conn = new SqlConnection("Server=xxxxx;User=xxxxx;Database=xxxxx");
//I'll be calling a Stored Procedure instead of this sql statement
SqlDataAdapter adapter1 = new SqlDataAdapter("INSERT INTO test
(test_type,test_desc,test_date,owner_name,owner_account,test_name,cust_name,
cust_phone,cust_fax,test_status) values ('x','x','04-20-2004','x', 'x', 'x',
'x', '0000','0000', 'Accepted')",conn);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top