The error is must declare the scalar Variable '@AppID'Code:dim Insert as string="insert into acaps(AppId,activity_dt,activity_cd,process_state,UserId,SeqNbr,LocCode,comments) values (@AppId,@activity_dt,@activity_cd,@process_state,@UserId,@SeqNbr,@LocCode,@comments)" Dim x As New Odbc.OdbcDataAdapter(selectQ.ToString, DirectCast(Me._Cn, Odbc.OdbcConnection)) If x.InsertCommand Is Nothing Then x.InsertCommand = New Odbc.OdbcCommand(insert) Else x.InsertCommand.CommandText = insert End If x.InsertCommand.Connection = DirectCast(Me._Cn, Odbc.OdbcConnection) x.InsertCommand.CommandTimeout = InsertTimeout For index As Integer = 0 To ColList.Count - 1 Select Case srcData.Columns(index).DataType.FullName Case "System.String" x.InsertCommand.Parameters.Add(New Odbc.OdbcParameter("@" + ColList(index), System.Data.DbType.String)) Case "System.DateTime" x.InsertCommand.Parameters.Add(New Odbc.OdbcParameter("@" + ColList(index), System.Data.DbType.Date)) Case Else MsgBox(srcData.Columns(index).DataType.FullName) Stop End Select x.InsertCommand.Parameters.Item("@" + ColList(index)).SourceColumn = ColList(index) x.InsertCommand.Parameters.Item("@" + ColList(index)).SourceVersion = DataRowVersion.Current 'x.InsertCommand.Parameters.Add(New Odbc.OdbcParameter(ColList(index), srcData.Columns(index).GetType)) Next 'If rollbackOnException Then ' Me.TestMode = True 'End If 'Dim da As System.Data.Common.DataAdapter = Me.chDataAdapter(selectQ.ToString, Me._Cn) For index As Integer = 0 To srcData.Rows.Count - 1 srcData.Rows(index).SetAdded() Next Fill = x.Update(srcData) srcData.AcceptChanges()
I'm not practiced in using parameters but I'm trying to follow the example at:
http://msdn.microsoft.com/en-us/library/ms810297.aspx
And have been trying things, but haven't found how to get it fire. At run time when I look at the value of the @Appid paramter it has the first row's value so it doesn't appear to be that.




Reply With Quote