I have been using VB.NET for a while now, and I can make a ton of things. But for some reason, I can't connect to SQL.

I use SQL 2008 express, and Visual Basic 2008 express(will soon get Visual studio :))

So, I go to add a database, I enter the name of my database, and will not connect. I get errors, and a lot of them too.

I'm only 11, and need help!

We also encounter a lot of problems with SQL database connection. when we start our project. There may be something wrong with the SQL server. try to use mysql, this one is better. I say it is better because we finally make our sql server work with mysql :)

to find out what is the problem you better post the errors you get.

We also encounter a lot of problems with SQL database connection. when we start our project. There may be something wrong with the SQL server. try to use mysql, this one is better. I say it is better because we finally make our sql server work with mysql :)

I can't use MySQL because they don't have anything for x32 Windows vista.
only x64 and x82

its gotto have x86
thts the option u have to select
if ur pc has 32 bit processor

I have been using VB.NET for a while now, and I can make a ton of things. But for some reason, I can't connect to SQL.

I use SQL 2008 express, and Visual Basic 2008 express(will soon get Visual studio :))

So, I go to add a database, I enter the name of my database, and will not connect. I get errors, and a lot of them too.

I'm only 11, and need help!

i dnt think sqlexpress will work
u gotto install sql developers edition

I am using MSSQL 2005
and VISUAL STUDIO 2005
hope you may get some help....

Dim con As SqlConnection
        Dim sql As String
        Dim cmd As SqlCommand

        con = New SqlConnection("Server=urserver;" & "DataBase=;" & "Integrated Security=ur security;")
        sql = "CREATE DATABASE ABC  ON PRIMARY" + "(Name=abc_data, filename = 'C:\MSSQL7\data\abc.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=abc_log, filename='C:\MSSQL7\abc_log.ldf',size=3," + "maxsize=20,filegrowth=1)"
        con.Open()

        cmd = New SqlCommand(sql, con)

        Try
            cmd.ExecuteNonQuery()
            MsgBox("DATABASE Created")
        Catch ex As Exception
            MsgBox("Database Already Exists!")
        End Try

i dnt think sqlexpress will work
u gotto install sql developers edition

Oh yeah, sure! I will just go and pull 50 dollers out of the air and buy SQL!

I'm 11, what d you think I'm made of, Money?!

I am using MSSQL 2005
and VISUAL STUDIO 2005
hope you may get some help....

Dim con As SqlConnection
        Dim sql As String
        Dim cmd As SqlCommand

        con = New SqlConnection("Server=urserver;" & "DataBase=;" & "Integrated Security=ur security;")
        sql = "CREATE DATABASE ABC  ON PRIMARY" + "(Name=abc_data, filename = 'C:\MSSQL7\data\abc.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=abc_log, filename='C:\MSSQL7\abc_log.ldf',size=3," + "maxsize=20,filegrowth=1)"
        con.Open()

        cmd = New SqlCommand(sql, con)

        Try
            cmd.ExecuteNonQuery()
            MsgBox("DATABASE Created")
        Catch ex As Exception
            MsgBox("Database Already Exists!")
        End Try

Where would i put this, in form1_load?

define global:

Dim con As New SqlConnection("Server=urserver;" & "DataBase=;" & "Integrated Security=ur security;")
        Dim sql As String
        Dim cmd As SqlCommand

in this way you can reuse the defined variables over the whole form without defining them again and again.
on form load you can then do:

sql = "CREATE DATABASE ABC  ON PRIMARY" + "(Name=abc_data, filename = 'C:\MSSQL7\data\abc.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=abc_log, filename='C:\MSSQL7\abc_log.ldf',size=3," + "maxsize=20,filegrowth=1)"
        con.Open()

        cmd = New SqlCommand(sql, con)

        Try
            cmd.ExecuteNonQuery()
            MsgBox("DATABASE Created")
        Catch ex As Exception
            MsgBox("Database Already Exists!")
        End Try

But i would suggest to change the sql command to check if the table exist instead of trying to create it new and just catching the error. there are more possible errors such as database not found and so on.

define global:

Dim con As New SqlConnection("Server=urserver;" & "DataBase=;" & "Integrated Security=ur security;")
        Dim sql As String
        Dim cmd As SqlCommand

in this way you can reuse the defined variables over the whole form without defining them again and again.
on form load you can then do:

sql = "CREATE DATABASE ABC  ON PRIMARY" + "(Name=abc_data, filename = 'C:\MSSQL7\data\abc.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=abc_log, filename='C:\MSSQL7\abc_log.ldf',size=3," + "maxsize=20,filegrowth=1)"
        con.Open()

        cmd = New SqlCommand(sql, con)

        Try
            cmd.ExecuteNonQuery()
            MsgBox("DATABASE Created")
        Catch ex As Exception
            MsgBox("Database Already Exists!")
        End Try

But i would suggest to change the sql command to check if the table exist instead of trying to create it new and just catching the error. there are more possible errors such as database not found and so on.

Yeah... i will have to try that out. Thanks. I want this to stay open more more people to post thire help.

define global:

Dim con As New SqlConnection("Server=urserver;" & "DataBase=;" & "Integrated Security=ur security;")
        Dim sql As String
        Dim cmd As SqlCommand

in this way you can reuse the defined variables over the whole form without defining them again and again.
on form load you can then do:

sql = "CREATE DATABASE ABC  ON PRIMARY" + "(Name=abc_data, filename = 'C:\MSSQL7\data\abc.mdf', size=3," + "maxsize=5, filegrowth=10%)log on" + "(name=abc_log, filename='C:\MSSQL7\abc_log.ldf',size=3," + "maxsize=20,filegrowth=1)"
        con.Open()

        cmd = New SqlCommand(sql, con)

        Try
            cmd.ExecuteNonQuery()
            MsgBox("DATABASE Created")
        Catch ex As Exception
            MsgBox("Database Already Exists!")
        End Try

But i would suggest to change the sql command to check if the table exist instead of trying to create it new and just catching the error. there are more possible errors such as database not found and so on.

Hi GeekByChoice,
You are right! there can be many possible errors....database not found(as you suggested), connection error..to name a few.. but i gave only one..just to give an idea... ;)

Hi GeekByChoice,
You are right! there can be many possible errors....database not found(as you suggested), connection error..to name a few.. but i gave only one..just to give an idea... ;)

I get connection errors. adn i hate them, if i see one more, i will pull out a M-80 and blow up my computer.

I get connection errors. adn i hate them, if i see one more, i will pull out a M-80 and blow up my computer.

Patient mate, patient :twisted:

>_<

So mich for having my own V-OS(Vurtual Operation System)...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.