Click here to Skip to main content
14,699,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i want to connect my application to sql server 2005 pls tell me that what will be the connection string

Please see[^]
I think it may be helpful to you.
Mehdi Gholam 16-Apr-12 14:22pm
5'ed, the standard link for this!
VJ Reddy 16-Apr-12 19:23pm
Thank you, Mehdi.
anand4886 16-Apr-12 14:55pm
i want to add data in sql server table from application,my code block is

Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlConnection

Public Class Form1
Dim cn As SqlConnection

Dim ConStr As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConStr = "Data Source=ANAND-PC\SQLEXPRESS;Initial Catalog=anand;User ID=;Password="
cn = New SqlConnection(ConStr)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmd As New SqlClient.SqlCommand
Dim query As String
query = "Insert Into anand1 (roll) values (" & TextBox1.Text & ");"

cmd.CommandText = query
cmd.CommandType = CommandType.Text
cmd.Connection = cn




End Sub
End Class

it is showing some error in

pls help its very urgent
Nelek 16-Apr-12 17:24pm
You should know than saying "pls help its very urgent" just brings the opposite effect. People here is helping for free in the spare time. So show a bit respect to them. If it is urgent, then use google, search and try it on your own, instead of posting in a forum and waiting for an answer.
VJ Reddy 16-Apr-12 19:36pm
It seems there is an issue with query. Please please this article It is in C#, but the concepts are easy to follow. If required, you can use for converting code from C# to VB.NET. Secondly, you can use the AddNewDataSource wizard in Visual Studio, from Data menu, which makes it easy to add a connection string through dialogs.
"Data Source=SERVERNAME;Initial Catalog=DATABASENAME;Persist Security Info=True;User ID=;Password="

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900