.net 2.0 SqlDependency
-
Hi, I am trying to get the SqlDependency to work in an application. Here is the problem: One windows application connects to northwind database using a user login. It then diplays the data in the Employees table. Another project is using the the login as the previous App to display the same data BUT it displays an error when it gets to da.Fill(ds, "Customer"); The error is: Message "When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance." string Thanks Here is code that I am using. ds.Clear(); SqlConnection conn = new SqlConnection(txtConnect.Text); conn.Open(); SqlCommand cmd = new SqlCommand(txtSelect.Text, conn); SqlDataAdapter da = new SqlDataAdapter(cmd); //SqlDependency.Start(txtConnect.Text); //test... SqlDependency dep = new SqlDependency(cmd); //The ERROR is on this line.../////// da.Fill(ds, "Employees"); ///////////////////////////////////// grdDemo.DataSource = ds; grdDemo.DataMember = "Employees";
-
Hi, I am trying to get the SqlDependency to work in an application. Here is the problem: One windows application connects to northwind database using a user login. It then diplays the data in the Employees table. Another project is using the the login as the previous App to display the same data BUT it displays an error when it gets to da.Fill(ds, "Customer"); The error is: Message "When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance." string Thanks Here is code that I am using. ds.Clear(); SqlConnection conn = new SqlConnection(txtConnect.Text); conn.Open(); SqlCommand cmd = new SqlCommand(txtSelect.Text, conn); SqlDataAdapter da = new SqlDataAdapter(cmd); //SqlDependency.Start(txtConnect.Text); //test... SqlDependency dep = new SqlDependency(cmd); //The ERROR is on this line.../////// da.Fill(ds, "Employees"); ///////////////////////////////////// grdDemo.DataSource = ds; grdDemo.DataMember = "Employees";
im sorry to see that you're having this problem. i have a library class that does sql connections and returnes data sets, etc. you dont have to use the class but it might help to look at/implement the code and see if you get the same error. Hope this link leads you to a solution to your problem
http://www.codeproject.com/dotnet/COperationsSQL.asp
all sqlconnections, commands, data adapters, are encapsulated in this class making things a little bit easier when it comes to interfacing with a sql back end. best of luck -
im sorry to see that you're having this problem. i have a library class that does sql connections and returnes data sets, etc. you dont have to use the class but it might help to look at/implement the code and see if you get the same error. Hope this link leads you to a solution to your problem
http://www.codeproject.com/dotnet/COperationsSQL.asp
all sqlconnections, commands, data adapters, are encapsulated in this class making things a little bit easier when it comes to interfacing with a sql back end. best of luck