|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Update Command with Parameter....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 A_PK wrote:
Show quoteHide quote > Could anyone pls guide me what is wrong with my Update Command cmd.Parameters.Add("imgarray",> > 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 = > SqlDbType.Image) I've always been told that the ? syntax for parameters is an ODBC> 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 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 Hi ....I tried the following code u gave me...i am expericing Token Line
Error ...what the problem could be ? Show quoteHide quote "Larry Lard" <larryl***@hotmail.com> wrote in message news:1113474429.213146.101970@z14g2000cwz.googlegroups.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 > What's your exact error message?
A_PK wrote: Show quoteHide quote > Hi ....I tried the following code u gave me...i am expericing Token Line > Error ...what the problem could be ? > > > "Larry Lard" <larryl***@hotmail.com> wrote in message > news:1113474429.213146.101970@z14g2000cwz.googlegroups.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 > >
Only 2 Days left to get REALbasic 5.5 for FREE!
Execption Handling disection File Path (Application Path) Dependency Error: The dependency <dll> in project <project> cannot be coppied to the run directory b Data Relation question enum item from string Re: THE GREATEST NEWS EVER! °º·._._.·º°`°º·._._.·º°`°º·._._.·º°`°º·._._.·º°`°º·._._.·º°`°º·._._.·º°` No one Find Directory created by me... run file remotely Stepping into a referenced assembly |
|||||||||||||||||||||||