PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

cmd.Parameters.Add(new OleDbParameter NOT TAKING ???

 
 
jason@cyberpine.com
Guest
Posts: n/a
 
      12th Feb 2005
Hello,


I can't get the below update to work. Here's what I know..
If I enter fixed strings in the update it works. The response.write
displays show good and updated values in the s strings. However, only
the @chain cmd.Param gets set, all others,like @responsible either
never get set or remain as they were. Strangley, I have this code in
another subroutine whree I'm adding a brand new record and it works
fine. I've copied the block of working text in and view the source in
hex and everything looks fine. I need another pair of eyes.

THANK YOU.


Public Sub UserGrid_Update (Source As Object, E As
DataGridCommandEventArgs)
Dim objConn as new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=x.mdb")

Dim cmd As OleDbCommand = new OleDbCommand ("UPDATE tbl SET
status=@status, responsible=@responsible WHERE chain=@chain", objConn)

Dim schain As String = e.Item.Cells(2).Text
Dim sresponsible As String = CType(e.Item.Cells(3).Controls (0),
TextBox).Text
Dim sstatus As String = CType(e.Item.Cells(4).Controls (0),
TextBox).Text
Dim swaitingon As String = CType(e.Item.Cells(5).Controls (0),
TextBox).Text
Dim scomments As String = CType(e.Item.Cells(6).Controls (0),
TextBox).Text


response.write(schain+"-"+sresponsible+"-"+sstatus+"-"+swaitingon+"-"+scomments)

cmd.Parameters.Add(new OleDbParameter("@chain", schain))
cmd.Parameters.Add(new OleDbParameter("@responsible",
sresponsible))
cmd.Parameters.Add(new OleDbParameter("@status", sstatus))
cmd.Parameters.Add(new OleDbParameter("@waitingon", swaitingon))

cmd.Parameters.Add(new OleDbParameter("@comments", scomments))


objConn.Open()
cmd.ExecuteNonQuery()
objConn.Close

' UserGrid.EditItemIndex = -1
BindData()



End Sub

 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      12th Feb 2005
Hi Jason,

Try using question marks (?) instead of @name in sql statement and make sure
you set parameters in same order.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
SLODUG - Slovene Developer Users Group www.codezone-si.info

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
>
> I can't get the below update to work. Here's what I know..
> If I enter fixed strings in the update it works. The response.write
> displays show good and updated values in the s strings. However, only
> the @chain cmd.Param gets set, all others,like @responsible either
> never get set or remain as they were. Strangley, I have this code in
> another subroutine whree I'm adding a brand new record and it works
> fine. I've copied the block of working text in and view the source in
> hex and everything looks fine. I need another pair of eyes.
>
> THANK YOU.
>
>
> Public Sub UserGrid_Update (Source As Object, E As
> DataGridCommandEventArgs)
> Dim objConn as new
> OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=x.mdb")
>
> Dim cmd As OleDbCommand = new OleDbCommand ("UPDATE tbl SET
> status=@status, responsible=@responsible WHERE chain=@chain", objConn)
>
> Dim schain As String = e.Item.Cells(2).Text
> Dim sresponsible As String = CType(e.Item.Cells(3).Controls (0),
> TextBox).Text
> Dim sstatus As String = CType(e.Item.Cells(4).Controls (0),
> TextBox).Text
> Dim swaitingon As String = CType(e.Item.Cells(5).Controls (0),
> TextBox).Text
> Dim scomments As String = CType(e.Item.Cells(6).Controls (0),
> TextBox).Text
>
>
> response.write(schain+"-"+sresponsible+"-"+sstatus+"-"+swaitingon+"-"+scomments)
>
> cmd.Parameters.Add(new OleDbParameter("@chain", schain))
> cmd.Parameters.Add(new OleDbParameter("@responsible",
> sresponsible))
> cmd.Parameters.Add(new OleDbParameter("@status", sstatus))
> cmd.Parameters.Add(new OleDbParameter("@waitingon", swaitingon))
>
> cmd.Parameters.Add(new OleDbParameter("@comments", scomments))
>
>
> objConn.Open()
> cmd.ExecuteNonQuery()
> objConn.Close
>
> ' UserGrid.EditItemIndex = -1
> BindData()
>
>
>
> End Sub
>



 
Reply With Quote
 
jason@cyberpine.com
Guest
Posts: n/a
 
      12th Feb 2005

Miha Markic [MVP C#] wrote:
> ... make sure you set parameters in same order.



BINGO! I did not realize that mattered since names are defined, but it
does. What's funny is how in all my testing combination the order
(though changing) never matched. Thank you very much.

 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      12th Feb 2005
Nope. The @ symbol is the correct symbol to use.


"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:(E-Mail Removed)...
> Hi Jason,
>
> Try using question marks (?) instead of @name in sql statement and make
> sure you set parameters in same order.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> www.rthand.com
> SLODUG - Slovene Developer Users Group www.codezone-si.info
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hello,
>>
>>
>> I can't get the below update to work. Here's what I know..
>> If I enter fixed strings in the update it works. The response.write
>> displays show good and updated values in the s strings. However, only
>> the @chain cmd.Param gets set, all others,like @responsible either
>> never get set or remain as they were. Strangley, I have this code in
>> another subroutine whree I'm adding a brand new record and it works
>> fine. I've copied the block of working text in and view the source in
>> hex and everything looks fine. I need another pair of eyes.
>>
>> THANK YOU.
>>
>>
>> Public Sub UserGrid_Update (Source As Object, E As
>> DataGridCommandEventArgs)
>> Dim objConn as new
>> OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=x.mdb")
>>
>> Dim cmd As OleDbCommand = new OleDbCommand ("UPDATE tbl SET
>> status=@status, responsible=@responsible WHERE chain=@chain", objConn)
>>
>> Dim schain As String = e.Item.Cells(2).Text
>> Dim sresponsible As String = CType(e.Item.Cells(3).Controls (0),
>> TextBox).Text
>> Dim sstatus As String = CType(e.Item.Cells(4).Controls (0),
>> TextBox).Text
>> Dim swaitingon As String = CType(e.Item.Cells(5).Controls (0),
>> TextBox).Text
>> Dim scomments As String = CType(e.Item.Cells(6).Controls (0),
>> TextBox).Text
>>
>>
>> response.write(schain+"-"+sresponsible+"-"+sstatus+"-"+swaitingon+"-"+scomments)
>>
>> cmd.Parameters.Add(new OleDbParameter("@chain", schain))
>> cmd.Parameters.Add(new OleDbParameter("@responsible",
>> sresponsible))
>> cmd.Parameters.Add(new OleDbParameter("@status", sstatus))
>> cmd.Parameters.Add(new OleDbParameter("@waitingon", swaitingon))
>>
>> cmd.Parameters.Add(new OleDbParameter("@comments", scomments))
>>
>>
>> objConn.Open()
>> cmd.ExecuteNonQuery()
>> objConn.Close
>>
>> ' UserGrid.EditItemIndex = -1
>> BindData()
>>
>>
>>
>> End Sub
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Taking multiple parameters Tangier Microsoft Excel Discussion 1 6th Sep 2008 03:15 AM
Form constructor taking parameters by reference Nikola Skoric Microsoft C# .NET 7 16th Jan 2007 03:16 PM
Output parameters for OleDbParameter Chris Simmons Microsoft ADO .NET 0 1st Mar 2005 05:07 PM
OleDbParameter Query: Multiple parameters Steven K Microsoft ASP .NET 1 6th Mar 2004 05:33 AM
Installer - Taking Parameters from Command Line? Microsoft Microsoft Dot NET Framework 1 28th Nov 2003 07:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:46 PM.