Mufi,
I'm sorry, I screwed up ... the code I gave you was for getting data, not updating data. I'm sorry. Try this instead ... (you don't need to use the SqlCommandBuilder ... you're running a StoredProc, the command builder won't do anything for you. Likewise, you don't need the DataAdapter, that's only for filling DataSets).
SqlCommand sc = new SqlCommand("MyInsertStoredProc", MyConnection);
sc.CommandType = CommmandType.StoredProcedure;
sc.Parameters.Add("@MyPK", MyPK);
sc.ExecuteNonQuery();
Let's see if I can show you with your own code:
Dim SQLConn As SqlConnection
Dim SQLComm As SqlCommand
SQLComm = new SqlCommand()
With SQLComm
.CommandType = CommandType.StoredProcedure
.CommandText = "A11InsertMtrfitt"
.Connection = New SqlConnection(ConnectionString)
.Connection.Open()
.ExecuteNonQuery()
.Connection.Close()
End With
~~Bonnie
>Hi,
>
>First of all thanks for help
>
>I have tried following code but it did't work.
>it skip all line after
>.Fill(dsallmtrfitt,"A11mtrfitt").
>
>Try
> Dim SQLConn As SqlConnection
> Dim SQLDaMtrfitt As SqlDataAdapter
> Dim sqlCmdBldr As SqlCommandBuilder
> sqlCmdBldr = New SqlCommandBuilder(SQLDaMtrfitt)
> SQLDaMtrfitt = New SqlDataAdapter()
>
> With SQLDaMtrfitt
> .SelectCommand = New SqlCommand()
> With .SelectCommand
> .CommandType = CommandType.StoredProcedure
> .CommandText = "A11InsertMtrfitt"
> .Connection = New SqlConnection(ConnectionString)
> '.CommandType = CommandType.StoredProcedure
> '.CommandText = "A11InsertMtrfitt"
> .Parameters.Add("@empid", SqlDbType.Int, 4).Value =
>
>CType(CbEmpname.Items(CbEmpname.SelectedIndex), ListItem).ID
> .Parameters("@empid").Direction = ParameterDirection.Input
> .Parameters("@empid").SourceColumn = "A11empid"
>
> .Parameters.Add("@date", SqlDbType.DateTime, 8).Value = DtPicker1.Text
> .Parameters("@date").Direction = ParameterDirection.Input
> .Parameters("@date").SourceColumn = "A11date"
>
>
> .Parameters.Add("@hpphase1", SqlDbType.VarChar, 30)
> '.Parameters("@hpphase1").SourceColumn = LTrim(txtHpPhase1.Text)
>
> .Parameters.Add("@hpphase2", SqlDbType.VarChar, 30)
> '.Parameters("@hpphase2").SourceColumn = LTrim(txtHpPhase2.Text)
> .Parameters.Add("@hpphase3", SqlDbType.VarChar, 30)
> '.Parameters("@hpphase3").SourceColumn = LTrim(txtHpPhase3.Text)
>
> .Parameters.Add("@hpphase4", SqlDbType.VarChar, 30)
> '.Parameters("@hpphase4").SourceColumn = LTrim(txtHpPhase4.Text)
>
> .Parameters.Add("@type", SqlDbType.VarChar, 30)
> '.Parameters("@type").SourceColumn = LTrim(txtType.Text)
>
> .Parameters.Add("@total", SqlDbType.VarChar, 30)
> '.Parameters("@total").SourceColumn = LTrim(txtTotal.Text)
>
> .Parameters.Add("@others", SqlDbType.VarChar, 30)
> '.Parameters("@others").SourceColumn = LTrim(txtother.Text)
>
> .Parameters.Add("@Remarks", SqlDbType.VarBinary, 30)
> '.Parameters("@remarks").SourceColumn = LTrim(txtremarks.Text)
> .Connection = New SqlConnection(ConnectionString)
> End With
> .Connection.Open()
> dsa11mtrfitt.AcceptChanges()
> .Fill(dsa11mtrfitt, "A11MtrFitt")
> .Update(dsa11mtrfitt, "A11MtrFitt")
> .InsertCommand.Dispose()
> .InsertCommand.Connection.Close()
> ' End With
>
>Thanks in advance.