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
04/06/2007 05:56:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
04/06/2007 04:31:26
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01230092
Message ID:
01230151
Vues:
16
>Bonnie,
>
>Thanks for the help. I made the adjustments shown below, but VB is now objecting to my connection at runtime with "The ConnectionString property has not been initialized" though I'm using the name of my connection "Smooth", and it is at least compiling now!
>
> Dim sc As New SqlCommand
> Dim Smooth As New SqlConnection
> Dim ReturnValue As Integer
> sc = New SqlCommand("INSERT INTO Pix (FirstName, LastName) VALUES (@xyz, @abc)", Smooth)
> sc.Parameters.AddWithValue("@xyz", TextBox1.Text)
> sc.Parameters.AddWithValue("@abc", TextBox2.Text)
> Smooth.Open()
> ReturnValue = sc.ExecuteNonQuery()
> Smooth.Close()
>
>Thanks again,
>David.

But really where is the connectionstring for Smooth? You're instantiating it as a new SqlConnection. If you have it static (shared I think in VB) then do not define there as a new SqlConnection.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform