Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2008-06-20 : 08:40:05
|
Does anyone see a problem with this data fill? Dim myConnection As New SqlConnection("server=Serverone\NetSDK;database=pubs;Integrated Security=SSPI") Dim myCommand As New SqlDataAdapter(String.Format("select OrderName, ShippedDate, DeliveredDate from Orders where ShippedDate >= {0} and DeliveredDate <= {1}", CalendarCtrl.DisplayStartDate, CalendarCtrl.DisplayEndDate), myConnection) Dim ds As New DataSet() myCommand.Fill(ds, "Orders")JimUsers <> Logic |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-06-20 : 09:05:14
|
One problem is you are not using parameters, but simply building a string using String.Format() which is just like doing concatenation, so you will need to format, escape and/or delimit your date values. I strongly recommend to use a SqlCommand and set parameters:http://weblogs.sqlteam.com/jeffs/archive/2006/07/21/10728.aspxIn addition, I recommend using a dataTable if you are only filling up one table, not an entire DataSet which is a set of tables and relations and is much more heavy weight and unnecessary for just one table. (Yet, this is a common mistake everyone seems to make, not sure why) Even better, if you are just looping through the results once, or binding something to the results, use a SqlDataReader which is even more efficient.- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
JimL
SQL Slinging Yak Ranger
1537 Posts |
Posted - 2008-06-20 : 09:57:19
|
Thanks Jeff. I am afraid I am still very green at .netI agree and if I was designing this from scratch I would simply use the VS tools and connect to a SP.Howerver this is calendar add-in I am trying to get to work and using their code.[url]http://www.mediachase.com/Profile/CustomerDownloads.aspx?did=4[/url]VS gives me an error on the Data fill.JimUsers <> Logic |
|
|
|
|
|
|
|