Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I just INSERT a new record into a SQL table?
Message
De
03/06/2007 19:54:22
 
 
À
03/06/2007 19:25:48
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01230092
Message ID:
01230101
Vues:
17
Can you show us what you already have?

It should be as simple as this:
SqlCommand sc =  new SqlCommand("Insert into bob (xyz, abc) VALUES ( @xyz, @abc )", this.MyConnection);
sc.Parameters.Add("@xyz", MyTable.Rows[myrow]["xyz"]);
sc.Parameters.Add("@abc", MyTable.Rows[myrow]["abc"]);
sc.Connection.Open();
sc.ExecuteNonQuery();
sc.Connection.Close();
~~Bonnie


>All I need to do is add one record to one SQL table using a VB.NET form and I'm getting very frustrated because I'm used to the simplicity of VFP's SQL PassThrough.
>
>I don't need to display the contents of the table with Next, Previous etc.
>
>My VB form already has a Connection, a DataSet, a BindingSource and a TableAdapter, none of which I can get to do what I want.
>
>Worst comes to worst, I can write my data out to a disk file and read it into the SQL table by invoking a stored procedure that uses OPENROWSET with BULK, but there must be a better, easier and for me, simpler, way.
>
>Thanks,
>David.
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