Wrox Programmer Forums
|
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 31st, 2007, 05:45 AM
Registered User
 
Join Date: May 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection String(object)

I am new to Vb.net and I'me trying to store data to the sql databse using text fields. Everything seems ok but i've tried several connection strings but they wont work.Could somebody give a hand, please?

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim conn As New SqlClient.SqlConnection()
Dim cmd As New SqlClient.SqlCommand()
conn.ConnectionString = "Data Source=(local);Initial Catalog=myDatabase;Integrated Security=SSPI"
conn.Open()
cmd.Connection = conn
With cmd.Parameters
.Add(New SqlClient.SqlParameter("@Student_id", TextBox1.Text))
.Add(New SqlClient.SqlParameter("@FirstName", TextBox1.Text))
.Add(New SqlClient.SqlParameter("@LastName", TextBox2.Text))
.Add(New SqlClient.SqlParameter("@Email", TextBox3.Text))
.Add(New SqlClient.SqlParameter("@Module", TextBox1.Text))
End With

cmd.CommandText = "INSERT INTO <Students> (<field1>,<field2>,<field3>,<field4>,<field5>) VALUES (@Student_id, @FirstName, @LastName, @Email, @Module)"
Progress.Show()
End Sub


 
Old May 31st, 2007, 04:54 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

http://www.connectionstrings.com/

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
connection string Sheraz Khan ASP.NET 2.0 Basics 3 July 5th, 2007 08:33 AM
Connection String (Object) ssimkhan Visual Basic 2005 Basics 1 June 1st, 2007 10:41 AM
Connection String aadz5 JSP Basics 1 January 24th, 2005 04:36 AM
Connection Object shahchi1 ADO.NET 5 June 1st, 2004 11:48 PM
connection string aadz5 ASP.NET 1.0 and 1.1 Basics 4 October 20th, 2003 08:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.