473,508 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Command with Parameter....

Could anyone pls guide me what is wrong with my Update Command

Dim signbyte As Byte()
signbyte = GetByteArray() ' i create this function to return
ByteArray

Try
Dim cmd As New SqlCeCommand
cmd.Connection = myConnection

' Someone give me the following insert statement....this ?
parameter is working,
'but I modify to update statement with @ or ?, both not
working....
'cmd.CommandText = "insert into test (picture) values (?)"

cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = ? WHERE tid
= '" & vartid & "'"
Dim param As SqlCeParameter = cmd.Parameters.Add("imgarray",
SqlDbType.Image)
param.Value = signbyte
myConnection.Open()
cmd.ExecuteNonQuery()
myConnection.Close()

Catch sqex As SqlCeException
MessageBox.Show(sqex.ToString(), "DB operation failed")
Catch er As Exception
MessageBox.Show(er.ToString)
End Try
Nov 21 '05 #1
3 5832
A_PK wrote:
Could anyone pls guide me what is wrong with my Update Command

Dim signbyte As Byte()
signbyte = GetByteArray() ' i create this function to return
ByteArray

Try
Dim cmd As New SqlCeCommand
cmd.Connection = myConnection

' Someone give me the following insert statement....this ? parameter is working,
'but I modify to update statement with @ or ?, both not
working....
'cmd.CommandText = "insert into test (picture) values (?)"
cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = ? WHERE tid = '" & vartid & "'"
Dim param As SqlCeParameter = cmd.Parameters.Add("imgarray", SqlDbType.Image)
param.Value = signbyte
myConnection.Open()
cmd.ExecuteNonQuery()
myConnection.Close()

Catch sqex As SqlCeException
MessageBox.Show(sqex.ToString(), "DB operation failed")
Catch er As Exception
MessageBox.Show(er.ToString)
End Try

I've always been told that the ? syntax for parameters is an ODBC
thing; when using a direct SQL connection you should use the @name
parameter style. Try the following changes:

Change
cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = ? WHERE tid = '" &
vartid & "'"
To
cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = @imgarray WHERE tid
= '" & vartid & "'"

Change
Dim param As SqlCeParameter = cmd.Parameters.Add("imgarray",
SqlDbType.Image)
To
Dim param As SqlCeParameter = cmd.Parameters.Add("@imgarray",
SqlDbType.Image)

Making these changes meant this code worked for me on a normal (not CE)
SQL Server.

--
Larry Lard
Replies to group please

Nov 21 '05 #2
Hi ....I tried the following code u gave me...i am expericing Token Line
Error ...what the problem could be ?
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
A_PK wrote:
Could anyone pls guide me what is wrong with my Update Command

Dim signbyte As Byte()
signbyte = GetByteArray() ' i create this function to return
ByteArray

Try
Dim cmd As New SqlCeCommand
cmd.Connection = myConnection

' Someone give me the following insert statement....this

?
parameter is working,
'but I modify to update statement with @ or ?, both not
working....
'cmd.CommandText = "insert into test (picture) values

(?)"

cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = ?

WHERE tid
= '" & vartid & "'"
Dim param As SqlCeParameter =

cmd.Parameters.Add("imgarray",
SqlDbType.Image)
param.Value = signbyte
myConnection.Open()
cmd.ExecuteNonQuery()
myConnection.Close()

Catch sqex As SqlCeException
MessageBox.Show(sqex.ToString(), "DB operation failed")
Catch er As Exception
MessageBox.Show(er.ToString)
End Try

I've always been told that the ? syntax for parameters is an ODBC
thing; when using a direct SQL connection you should use the @name
parameter style. Try the following changes:

Change
cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = ? WHERE tid = '" &
vartid & "'"
To
cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = @imgarray WHERE tid
= '" & vartid & "'"

Change
Dim param As SqlCeParameter = cmd.Parameters.Add("imgarray",
SqlDbType.Image)
To
Dim param As SqlCeParameter = cmd.Parameters.Add("@imgarray",
SqlDbType.Image)

Making these changes meant this code worked for me on a normal (not CE)
SQL Server.

--
Larry Lard
Replies to group please

Nov 21 '05 #3

What's your exact error message?
A_PK wrote:
Hi ....I tried the following code u gave me...i am expericing Token Line Error ...what the problem could be ?
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
A_PK wrote:
Could anyone pls guide me what is wrong with my Update Command

Dim signbyte As Byte()
signbyte = GetByteArray() ' i create this function to return ByteArray

Try
Dim cmd As New SqlCeCommand
cmd.Connection = myConnection

' Someone give me the following insert statement....this
?
parameter is working,
'but I modify to update statement with @ or ?, both
not working....
'cmd.CommandText = "insert into test (picture) values

(?)"

cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = ?

WHERE tid
= '" & vartid & "'"
Dim param As SqlCeParameter =

cmd.Parameters.Add("imgarray",
SqlDbType.Image)
param.Value = signbyte
myConnection.Open()
cmd.ExecuteNonQuery()
myConnection.Close()

Catch sqex As SqlCeException
MessageBox.Show(sqex.ToString(), "DB operation failed") Catch er As Exception
MessageBox.Show(er.ToString)
End Try

I've always been told that the ? syntax for parameters is an ODBC
thing; when using a direct SQL connection you should use the @name
parameter style. Try the following changes:

Change
cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = ? WHERE tid =

'" & vartid & "'"
To
cmd.CommandText = "UPDATE bm00ts0001 SET imgarray = @imgarray WHERE tid = '" & vartid & "'"

Change
Dim param As SqlCeParameter = cmd.Parameters.Add("imgarray",
SqlDbType.Image)
To
Dim param As SqlCeParameter = cmd.Parameters.Add("@imgarray",
SqlDbType.Image)

Making these changes meant this code worked for me on a normal (not CE) SQL Server.

--
Larry Lard
Replies to group please


Nov 21 '05 #4

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

Similar topics

5
8283
by: Jason Huang | last post by:
Hi, The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is working for update, but SqlParameter myPM =new SqlParameter ("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is...
4
3380
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
8
2673
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
4
9683
by: drakuu | last post by:
Hello there, I have DataGrid with some records and I would like to edit it right in the datagrid using the built in commands. I can't figure out a way to pass to the SQL query the record ID...
0
1587
by: Luigi | last post by:
Hi all, I have the GridView with this code: <asp:GridView OnDataBound="VisualizzaExcel" EnableViewState="False" ID="GridView1" runat="server" AutoGenerateColumns="False"...
0
4330
by: troyblakely | last post by:
I have a gridview which is pulling data from a SqlDataSource, the select command queries a view and the update command is a stored procedure. I'm using a stored procedure because several tables...
4
7211
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
3
4778
by: Brad Baker | last post by:
I have a formview with a datasource that contains a select and update command. The select statement works fine but the update command doesn't seem to be working. After some troubleshooting I have...
2
2611
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
0
7124
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...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7046
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...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4707
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...
0
3195
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...
0
1558
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 ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.