Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need make tabale using sql comand in vb.net. my comand is below.but its wrong

VB
Dim conStr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\aInven\Database\esay_master_database.mdf;Integrated Security=True;User Instance=True"
Dim DBCon As New SqlConnection(conStr)
Dim obj As SqlCommand
Dim strSQL As String



' Create a table
conStr = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\aInven\Database\esay_master_database.mdf;Integrated Security=True;User Instance=True"
DBCon = New SqlConnection(conStr)
DBCon.Open()
obj = DBCon.CreateCommand()
strSQL = "CREATE TABLE " & TextBox2.Text & " (No int, Date text, Amount money, Cheque money, Cash money, Balance money, AC_No varchar(30), Cheque_no1 varchar(30), Cheque_no2 varchar(30), Released_date_cqe1 text, Released_date_cqe2 text, Value_cqe1 money, Value_cqe2 money PRIMARY KEY(NO))"

' Execute
obj.CommandText = strSQL
Try
    obj.ExecuteNonQuery()
Catch ex As Exception
    MessageBox.Show(ex.Message)
End Try
Posted
Updated 21-Jul-13 9:36am
v2
Comments
Basmeh Awad 21-Jul-13 15:38pm    
what exception are you getting??

1 solution

Hi,
I think your connection has problem.Did u check with your connection is that ok.Debug your code and check for your DB Connection.Check like this.

VB
Dim conStr As String = "Server=yourServerName;Database=YourDBName;Trusted_Connection = yes"
Dim objCon As New SqlConnection(conStr)
 
Share this answer
 

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