473,799 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UpdateCommand problem


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

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?

Thanks,
Stu

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

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
da.Update(ds, "CustSKUDateSet tings")
End Sub

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'TODO: This line of code loads data into the
'Viaware_arc_te stDataSet1.Cust SKUDateSettings ' table. You can move, or
remove it, as needed.
Dim conn As New Data.SqlClient. SqlConnection
conn.Connection String = "..."
ds = New DataSet
da = New Data.SqlClient. SqlDataAdapter
da.SelectComman d = New Data.SqlClient. SqlCommand
da.SelectComman d.Connection = conn
da.InsertComman d = New Data.SqlClient. SqlCommand
da.InsertComman d.Connection = conn
da.UpdateComman d = New Data.SqlClient. SqlCommand
da.UpdateComman d.Connection = conn

da.SelectComman d.CommandText = "Select rid, custnum, sku,
search_date_typ e, date_range, date_sort_order , days_to_start,
days_to_end from CustSKUDateSett ings"
da.Fill(ds, "CustSKUDateSet tings")
DataGridView1.D ataSource = ds.Tables("Cust SKUDateSettings ")
da.UpdateComman d.CommandText = " UPDATE dbo.test1 " & _
"SET sku = @SKU, " & _
"WHERE rid = @rid " & _
"CustNum = @CustNum, " &
_
"search_date_ty pe =
@search_date_ty pe," & _
"date_range =
@date_range," & _
"date_sort_orde r =
@date_sort_orde r," & _
"days_to_st art =
@days_to_start, " & _
"days_to_en d =
@days_to_end " & _
da.UpdateComman d.CommandType = System.Data.Com mandType.Text
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@rid", System.Data.Sql DbType.Int, 4,
"rid"))
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@SKU", System.Data.Sql DbType.Char,
20, "dbo.test1.sku" ))
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@CustNum" ,
System.Data.Sql DbType.[Char], 15, "CustNum"))
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@search_d ate_type",
System.Data.Sql DbType.[Char], 1, "search_date_ty pe"))
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@date_ran ge",
System.Data.Sql DbType.[Char], 1, "date_range "))
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@date_sor t_order",
System.Data.Sql DbType.[Char], 1, "date_sort_orde r"))
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@days_to_ start",
System.Data.Sql DbType.Int, 4, "days_to_start" ))
da.UpdateComman d.Parameters.Ad d(New
System.Data.Sql Client.SqlParam eter("@days_to_ end",
System.Data.Sql DbType.Int, 4, "days_to_en d"))

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3483
by: Mark | last post by:
Hi, I have a datalist that I use to display and edit records to a user. Datalist shown below; visual basic code:----------------------------------------------------------------------- ------- <asp:datalist id="dgContributors" runat="server" DataKeyField="PersonID"> <ItemTemplate>
1
1893
by: niki | last post by:
Hello. I have a problem with custom columns inside the datagrid. I've set up a datagrid that populates from a database; I can edit the datagrid values and update the db, so that's ok. (btw, it's not as easy as the book claims...) Now I'd like to format some columns, say date values, and what's more, I'd like to make some columns not visible and some read-only. I thought BoundColumn could be the solution, but as I create columns this...
3
2672
by: Jim in Arizona | last post by:
I'm doing my best to learn ASPNET from a book devoted to ASPNET 1.0. So far, I haven't run into any problems, until now. This is a simple page that should just show the sql strings created by the CommandBuilder (or is it data adapter) object. Here is my code (the books code, actually): <%@ Page Language="VB" %> <%@ Import Namespace="System.Data" %>
5
4605
by: Peter W Johnson | last post by:
Hi Guys, I am having problems getting the following code to update an Access table. I get the following error:- An unhandled exception of type 'System.NullReferenceException' occurred in MemberBase.exe Additional information: Object reference not set to an instance of an object.
2
13969
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
5
1414
by: wandii | last post by:
Hi, I am trying to update the customer table by using the updatecommd, please see below, however, when it runs it does not fire the update statement. I ran the sql profiler and the only statement the profiler shows is the 'Select * from Customers...' and zero rows updated. Does any knwo why the updatecommand does not fire.
1
4272
by: Rich | last post by:
Hello, I can update a dataset from my client app using a dataAdapter.Updatecommand when I add parameter values outside of the param declaration. But If I add the param values inline with the param delcaration, then I have to invoke the update operation twice - by leaving the updated row - returning to the row and re-invoking the update procedure. Is there something else I need to do to add param values inline with the param...
6
14002
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
0
1102
by: Giovanni | last post by:
Hi, I'm new in vs2k8 and I'm trying to build up an ASP application that uses a DB. Situation: 2 tables related by a key (pk->fk). A Gridview on a web page that show me the 2 tables join query's result. In grid's properties I wanted to show edit, delete and update links. Problem: When I edit the grid and I click update, i get an error:
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.