469,890 Members | 1,929 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

UpdateCommand problem

I have a SQL Server table with in Indetity column (value auto

I have tried to write my own updatecommand code.

I can't get it to work.
An error says that says Sku and rid are invalid column names. I don't
know why.

I even modified the Updatecommand the a bare bones
"UPDATE dbo.test1 SET sku = @SKU"
At least this gave me a different error!
The error says error in Prepared statement
"@SKU(20) Update dbo.test1 SET sku = @SKU"

Can anyone help?


Public da As Data.SqlClient.SqlDataAdapter, ds As DataSet, conn As

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
da.Update(ds, "CustSKUDateSettings")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'Viaware_arc_testDataSet1.CustSKUDateSettings' table. You can move, or
remove it, as needed.
Dim conn As New Data.SqlClient.SqlConnection
conn.ConnectionString = "..."
ds = New DataSet
da = New Data.SqlClient.SqlDataAdapter
da.SelectCommand = New Data.SqlClient.SqlCommand
da.SelectCommand.Connection = conn
da.InsertCommand = New Data.SqlClient.SqlCommand
da.InsertCommand.Connection = conn
da.UpdateCommand = New Data.SqlClient.SqlCommand
da.UpdateCommand.Connection = conn

da.SelectCommand.CommandText = "Select rid, custnum, sku,
search_date_type, date_range, date_sort_order, days_to_start,
days_to_end from CustSKUDateSettings"
da.Fill(ds, "CustSKUDateSettings")
DataGridView1.DataSource = ds.Tables("CustSKUDateSettings")
da.UpdateCommand.CommandText = " UPDATE dbo.test1 " & _
"SET sku = @SKU, " & _
"WHERE rid = @rid " & _
"CustNum = @CustNum, " &
"search_date_type =
@search_date_type," & _
"date_range =
@date_range," & _
"date_sort_order =
@date_sort_order," & _
"days_to_start =
@days_to_start," & _
"days_to_end =
@days_to_end " & _
da.UpdateCommand.CommandType = System.Data.CommandType.Text
System.Data.SqlClient.SqlParameter("@rid", System.Data.SqlDbType.Int, 4,
System.Data.SqlClient.SqlParameter("@SKU", System.Data.SqlDbType.Char,
20, "dbo.test1.sku"))
System.Data.SqlDbType.[Char], 15, "CustNum"))
System.Data.SqlClient.SqlParameter("@search_date_t ype",
System.Data.SqlDbType.[Char], 1, "search_date_type"))
System.Data.SqlDbType.[Char], 1, "date_range"))
System.Data.SqlClient.SqlParameter("@date_sort_ord er",
System.Data.SqlDbType.[Char], 1, "date_sort_order"))
System.Data.SqlClient.SqlParameter("@days_to_start ",
System.Data.SqlDbType.Int, 4, "days_to_start"))
System.Data.SqlDbType.Int, 4, "days_to_end"))

*** Sent via Developersdex http://www.developersdex.com ***
Jul 1 '08 #1
0 833

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mark | last post: by
1 post views Thread by niki | last post: by
3 posts views Thread by Jim in Arizona | last post: by
5 posts views Thread by Peter W Johnson | last post: by
2 posts views Thread by susan.f.barrett | last post: by
5 posts views Thread by wandii | last post: by
reply views Thread by Giovanni | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.