Create Sql server DataBase by vb6

this my first thread

this Simple code use for create sql server database , you can enter any name to the textbox in this code ....

the controls

Textbox 1 , Button

references

Microsoft Activx Data object 2.0

' in general section

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset

in command click event this code

Private Sub Command1_Click()

Set rst = New ADODB.Recordset
Set cnn = New ADODB.Connection

cnn.ConnectionString = "Provider=SQLOLEDB.1" & _
";Integrated Security=SSPI;Persist Security Info=False;" & _
"User ID=Gihad alariqi;Initial Catalog=gehad;" & _
"Data Source=GIHAD\SQLEXPRESS"

'"Data Source=GIHAD\SQLEXPRESS;Initial Catalog=gehad;Integrated Security=True "
cnn.Open

rst.Open "CREATE DATABASE " & Text1.Text & "", cnn

End Sub

regards:wave:
[937 byte] By [gehad] at [2007-12-5 10:15:13]
# 1 Re: Create Sql server DataBase by vb6
Ok? So you can create a database using ADO.
Why did you post this?
kaffenils at 2007-12-6 10:39:07 >
# 2 Re: Create Sql server DataBase by vb6
Moved to the CodeBank
Hack at 2007-12-6 10:40:07 >
# 3 Re: Create Sql server DataBase by vb6
bleh... and using a recordset to do that too... better to use a Command object then .Execute it.

-tg
techgnome at 2007-12-6 10:41:06 >
# 4 Re: Create Sql server DataBase by vb6
Moved to the CodeBank

Move to trashcan instead :p
kaffenils at 2007-12-6 10:42:13 >
# 5 Re: Create Sql server DataBase by vb6
i think a name change is required on this ??

Dav
Davadvice at 2007-12-6 10:43:12 >
# 6 Re: Create Sql server DataBase by vb6
Don't get me wrong... I mean it'll work... it's just not the way one would go about doing it generally.

-tg
techgnome at 2007-12-6 10:44:11 >