getting error "fill:select command.connection property has not been initialized

Posted by Chanti444 under ASP.NET on 12/6/2011 | Points: 10 | Views : 4514 | Status : [Member] | Replies : 4
hi

can any body help me why is getting these error here also post my source code please check it once and tell me where is wrong in my source code

satya


Responses

Posted by: Jpchoudhari on: 12/6/2011 [Member] Starter | Points: 25

Up
0
Down
Hi

u have to initialize connection object first with new keyword and then open the connection.
SqlConnection con = new SqlConnection("connectionString");
con.Open();

Kind Regards,
Jay

Chanti444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bees7000 on: 12/6/2011 [Member] Starter | Points: 25

Up
0
Down
string conStr="you connection string"
SqlConnection con=new SqlConnection(conStr);
SqlCommand cmd=new SqlCommand("your Sql Command",con);
con.Open();
Cmd.ExecuteNonQuery();

Marwan

Chanti444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Varung on: 12/7/2011 [Member] Starter | Points: 25

Up
0
Down
u have to include
cmd.Connection=con;
where con=object of SqlConnection
cmd=object of SqlCommand

G.Varun

Chanti444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 12/7/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

I checked your code. The reason for this error is that you didn't open the connection before execute the query. You should call the function "connectionopen()" after first statement (string str=...) of the function "getquestion(int no)"

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Chanti444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response