B
bob
Can anyone help me connect to SQL Server???
I am new to all this... it is been a titanic struggle consuming hours &
days & ....
I am trying to create an SQL database programatically. But my code
stalls before it gets started, and can't establish a connection to SQL
Server.
Here is my code:
========================================================
Sub MakeDatabase()
Dim cn As New SqlConnection, cmd As New SqlCommand
Dim connect$, sql$
connect$ = "Data Source=(local); Integrated Security=SSPI;
Initial Catalog=;"
cn.ConnectionString = Connect$
Try
cn.Open()
Catch ae As SqlException
MsgBox(ae.Message.ToString, MsgBoxStyle.Critical, "SQL
Connection")
Exit Sub
End Try
sql$ = "CREATE DATABASE Cf"
cmd.Connection = cn
cmd.CommandText = sql$
cmd.ExecuteNonQuery()
cn.Close()
End Sub
This thing stalls and can't connect, giving me an error #5. The error
message suggest that my installed SQL might not allow "remote access".
But I checked and it does. I am using VB 2005 Express and SQL 2005
Express.
I am new to all this... it is been a titanic struggle consuming hours &
days & ....
I am trying to create an SQL database programatically. But my code
stalls before it gets started, and can't establish a connection to SQL
Server.
Here is my code:
========================================================
Sub MakeDatabase()
Dim cn As New SqlConnection, cmd As New SqlCommand
Dim connect$, sql$
connect$ = "Data Source=(local); Integrated Security=SSPI;
Initial Catalog=;"
cn.ConnectionString = Connect$
Try
cn.Open()
Catch ae As SqlException
MsgBox(ae.Message.ToString, MsgBoxStyle.Critical, "SQL
Connection")
Exit Sub
End Try
sql$ = "CREATE DATABASE Cf"
cmd.Connection = cn
cmd.CommandText = sql$
cmd.ExecuteNonQuery()
cn.Close()
End Sub
This thing stalls and can't connect, giving me an error #5. The error
message suggest that my installed SQL might not allow "remote access".
But I checked and it does. I am using VB 2005 Express and SQL 2005
Express.