I am using vb .net 2003 and sql 2000,and I am trying to create a database using textboxes to name them and I keep getting syntax errors with this code.
Dim cmd As New SqlCommand(strSQL, cn)
Dim res As String
res = TB1.Text
Dim strSQL As String = _
"IF EXISTS (" & _
"SELECT * " & _
"FROM master..sysdatabases " & _
"WHERE Name = )" + res & vbCrLf & _
"DROP DATABASE " + res & vbCrLf & _
"CREATE DATABASE " + res
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
Can anyone help me out with this problem?
Thanks in advance,
Marty
Dim cmd As New SqlCommand(strSQL, cn)
Dim res As String
res = TB1.Text
Dim strSQL As String = _
"IF EXISTS (" & _
"SELECT * " & _
"FROM master..sysdatabases " & _
"WHERE Name = )" + res & vbCrLf & _
"DROP DATABASE " + res & vbCrLf & _
"CREATE DATABASE " + res
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
Can anyone help me out with this problem?
Thanks in advance,
Marty