Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hai, i have a probleam with sql command .Here is my code which iam try to add data in database. For your info i am using sql server 2005. Please help me to correct my coding.

Imports System.Data.SqlClient

Public Class page

Private Sub btnaddsuplier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddsuplier.Click

Dim connection As New SqlConnection
connection.ConnectionString = " Data Source=Danawa;Initial Catalog=Store;Integrated Security=True"
Dim cmd1 As SqlCommand
dim ra as integer

Try
connection.Open()
cmd1 = New SqlCommand("INSERT INTO dealer (dname) VALUES ('" & txtadddeletesupplier.Text & "')", connection)
ra = cmd.ExecuteNonQuery()
MsgBox("Category Added!!", MsgBoxStyle.Information, "Record Added = " & ra)
Catch ex As Exception
MsgBox("Category Failed to add!!", MsgBoxStyle.Critical)
End Try

end sub
end class
Posted
Updated 15-Oct-11 17:47pm
v3
Comments
theanil 16-Oct-11 2:27am    
What is the error you are getting?
Muhammad Shahid Farooq 16-Oct-11 3:00am    
You didn't mentioned the error, How we help you ?

1 solution

How many columns do you have in the dealer table? If you have more than one, then this query should hold all the values that need to be inserted into the table (unless all the other columns have defaults set).
 
Share this answer
 
v2
Comments
Muhammad Shahid Farooq 16-Oct-11 3:02am    
If you didn't understand the problem then why you use the Solution space ? There is a space for "Have a Question or Comment?"

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