Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2004

Tip: Looking for answers? Try searching our database.

ORA-01008: Not all variables bound Error.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ksedran - 14 Oct 2004 18:51 GMT
Hi all,

I am getting this ORA-01008: Not all variables bound error when trying to
update an Oracle table from a datagrid using VB.NET.

'Code to load Datagrid---------

Private Sub TransactionDetail_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

da = New OracleDataAdapter("select MSG_TYPE from IN_DRAFT_MAIN WHERE
TRANS_SEQ_NBR = '" & passedTSN & "'", Conn)
da.Fill(ds, "IN_DRAFT_MAIN")
DG_InDraftMain.DataSource = ds
DG_InDraftMain.DataMember = "IN_DRAFT_MAIN"

ts.MappingName = "IN_DRAFT_MAIN"

Dim col1 As New DataGridTextBoxColumn
           With col1
               .MappingName = "MSG_TYPE"
               .HeaderText = "MSG_TYPE"
               .NullText = String.Empty
           End With

        With ts.GridColumnStyles
               .Add(col1)
           End With

DG_InDraftMain.TableStyles.Add(ts)
End Sub

'Updates IN_DRAFT_MAIN Table
Private Sub bt_update_InDraftMain_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles bt_update_InDraftMain.Click
       
Dim cmd As New OracleCommand("Update IN_DRAFT_MAIN set MSG_TYPE= :MSG_TYPE
WHERE TRANS_SEQ_NBR= :TRANS_SEQ_NBR")

           da.UpdateCommand = cmd
           cmd.Connection = Conn
           Conn.Open()
           cmd.ExecuteNonQuery()
   End Sub

I have tried several things without success. It seems the issue is in the
UPDATE command with the :MSG_TYPE and :TRANS_SEQ_NBR syntax.
If I replace these with real values, it executes properly.  
ie. SET MSG_TYPE = '1111' WHERE TRANS_SEQ_NBR = '5323442'

Any ideas?

Thanks in advance,
Signature

Kevin

ratna veta - 14 Oct 2004 20:36 GMT
Hi,

The problem should be with the bound variables and the column mapping. I
did not see any parameters set for the update command. If you have set
it elsewhere the column name for the parameter should be set correctly
otherwise this error comes up

oUpdCmd.Parameters.Add(New OracleParameter("MSG_TYPE ",
OracleType.Number, 0, "MSG_TYPE ")).

I think you did nt set any parameters like this in your code that is the
reason for ur error.

thanks
ksedran - 14 Oct 2004 22:05 GMT
Ratna,

Thanks for the help. I added the following to the update button click, but
am still gettting the same error:

Dim cmd As New OracleCommand("Update IN_DRAFT_MAIN set MSG_TYPE= :MSG_TYPE
WHERE TRANS_SEQ_NBR= :TRANS_SEQ_NBR")

cmd.Parameters.Add(New OracleParameter(":MSG_TYPE", OracleType.Number, 1,
"MSG_TYPE"))
cmd.Parameters.Add(New OracleParameter(":TRANS_SEQ_NBR", OracleType.Number,
1, "TRANS_SEQ_NBR"))

cmd.Connection = Conn
Conn.Open()
da.UpdateCommand = cmd
cmd.ExecuteNonQuery()

Here is all the code:

Dim Conn As New OracleConnection("Data Source= " & DataBase & "; user id = "
& username & "; password =" & userpassword & "")

   Dim da As New OracleDataAdapter
   Dim ds As New DataSet
   Dim ts_InDraftMain As DataGridTableStyle = New DataGridTableStyle
   
Private Sub TransactionDetail_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

       Me.Cursor = Cursors.WaitCursor

       ' START of IN_DRAFT_MAIN Grid load  *************
da = New OracleDataAdapter("select TRANS_SEQ_NBR, MSG_TYPE from
IN_DRAFT_MAIN WHERE TRANS_SEQ_NBR = '" & passedTSN & "'", Conn)
           da.Fill(ds, "IN_DRAFT_MAIN")
           DG_InDraftMain.DataSource = ds
           DG_InDraftMain.DataMember = "IN_DRAFT_MAIN"

           ts_InDraftMain.MappingName = "IN_DRAFT_MAIN"

           'clears old table and column styles before creating new one.
           DG_InDraftMain.TableStyles.Clear()
           ts_InDraftMain.GridColumnStyles.Clear()

           Dim col1Grid1 As New DataGridTextBoxColumn
           Dim col2Grid1 As New DataGridTextBoxColumn
           
           With col1Grid1
               .MappingName = "TRANS_SEQ_NBR"
               .HeaderText = "TRANS_SEQ_NBR"
               .NullText = String.Empty
           End With

           With col2Grid1
               .MappingName = "MSG_TYPE"
               .HeaderText = "MSG_TYPE"
               .NullText = String.Empty
           End With

           With ts_InDraftMain.GridColumnStyles
               .Add(col1Grid1)
               .Add(col2Grid1)
           End With

           ' Add the GridColumnStyles to the aGridTableStyle.
           DG_InDraftMain.TableStyles.Add(ts_InDraftMain)

   End Sub

   Private Sub bt_update_InDraftMain_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles bt_update_InDraftMain.Click

           Dim cmd As New OracleCommand("Update IN_DRAFT_MAIN set MSG_TYPE=
:MSG_TYPE WHERE TRANS_SEQ_NBR= :TRANS_SEQ_NBR")
           cmd.Parameters.Add(New OracleParameter(":MSG_TYPE",
OracleType.Number, 1, "MSG_TYPE"))
           cmd.Parameters.Add(New OracleParameter(":TRANS_SEQ_NBR",
OracleType.Number, 1, "TRANS_SEQ_NBR"))
           cmd.Connection = Conn
           Conn.Open()
           da.UpdateCommand = cmd
           cmd.ExecuteNonQuery()

   End Sub

> Hi,
>
[quoted text clipped - 10 lines]
>
> thanks
ratna veta - 14 Oct 2004 22:45 GMT
Hi,

I guess you should use da.update method instead of cmd.executenonquery
as ur updating using dataadapter.

thanks
ksedran - 14 Oct 2004 23:15 GMT
Yup, that did the trick!!

Thank you very much for helping Ratna, I really appreciate it!

> Hi,
>
> I guess you should use da.update method instead of cmd.executenonquery
> as ur updating using dataadapter.
>
> thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.