Sign up to the jQuery Grid Subscription list.

How to add a new record (

Original post by Jarge at

The question:

Ok i have an unbound text box

i also have a command button that does nothing.

I need to be able to have whatever i type into the text box to be entered into a table.

how can i do this?

for the record i know extremely little about VBA, i can copy and paste, and edit bits if im told what, when and where to edit but apart from that i'm useless.

Any help will be greatly appreciated.

The accepted answer by Spotty:

From what you said, you are leaving out real important points

A table, what sort of database are you using, does you applicable actually already use the database in any way already ?

What version of VB are you using ?

All these points determine a solution. The technology you are probably going to be using is called ADO.NET and you are going to be using a Command Object. A web search on ADO.NET + VB.NET + INSERT QUERY will probably reveal quite a few basic examples.

Something a simple as may work.
Dim con As SqlConnection
con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI")
Dim cmd As New SqlCommand()
cmd.Connection = con
cmd.CommandText = "INSERT INTO Employee (FirstName) VALUES (@FirstName)"
' 2. Map parameters
cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 10, "FirstName")
cmd.Parameters("@FirstName").Value = Textbox1.text
End Try


Related Ads