Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert Data
Message
De
20/04/2003 11:32:42
 
 
À
20/04/2003 06:29:14
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Divers
Thread ID:
00779465
Message ID:
00779618
Vues:
14
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);
// Add all other parameters here

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)
                  
                    'Now, add all your parameters

                    .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.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform