Skip to content

PLEASE HELP!!! VB Database Connection

Erhan Suvari

Asked Feb 28, 2006, 4:17 AM EST4 answers
Share
LinkedInX
Hi, I am Visual Basic beginner needing help desperately.

I am using Microsoft Visual Studio.Net 2003. I have a basic Form with 3 Labels and 1 Button.

I also have a Database with 3 Fields.

I want the Text from Label1, Label2 and Label 3 to be stored in the database when Button 1 is clicked.

Please can someone help me to do this, with sample code, including the database connection.

Thanks

ensuvari

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Lets say u r using a SQL 2000 database righ ++++++++++ Dim cmdAdd As New SqlClient.SqlCommand Dim drAdd As SqlClient.SqlDataReader Dim strUsers as String Dim Con As New SQLConection +++++++++++ Con = New SqlConnection("workstation id=YOUR WORK STATION ID;packet size=4096;integrated security=SSPI;data source=YOUR WORK STATION ID;persist security info=False;initial catalog=Security") +++++++++++++++ Con.Close() Con.Open() cmdAdd.Connection = con cmdAdd.CommandText = "Insert into YOUR TABLE NAME values(" & Field Name 1 = " & Label 1 & ", Field Name 2 = " & Label 2 & ", Field Name 3 = " & Label 3 & " )" ++++++++++++++++ drAdd = cmdAdd.ExecuteReader Con.Close() +++++++++++++++++++ This should work like a breeze if u have any problems with this code let me know cheerz 4 now Dancin Fingerz PS>>>>>> Where I have the "++++++++" skip a line ....!
    0
  • 0

    Thanks a lot

    I'm using MS Access 2000 should that make a difference?

    Also, I forgot to mention that as well as the 3 fields, I also have an AutoNumber Primary Key Field. Should this populate automatically, or will I need to include coding for it?

    0
  • 0
    hello

    are you using sql server? Or oracle ?

    Plz specify.

    Thanks
    0
  • 0
    Thanks for your help.

    I have solved this problem.
    0