Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
       Dim Con As New SqlConnection
       Con.ConnectionString = "Data Source=12.18.1.77;Initial Catalog=ACC_FG;User ID=sa;Password=***********"
       Dim cmd As New SqlCommand
       Dim status As String
       Dim ra As Integer
       If (RadioButton1.Checked) Then
           status = "title"
       ElseIf (RadioButton2.Checked) Then
           status = "regular"
       Else
           status = ""

       End If
       Dim cost As String
       If (CheckEdit1.Checked) Then
           cost = "Branches"
       ElseIf (CheckEdit2.Checked) Then
           cost = "Departments"
       ElseIf (CheckEdit3.Checked) Then
           cost = "projects"
       ElseIf (CheckEdit4.Checked) Then
           cost = "cost centres"
       Else
           cost = ""
       End If

       Try
           Con.Open()

           cmd.Connection = Con

           cmd = New SqlCommand("insert into Accounts values ('" & TextEdit1.Text & "','" & TextEdit2.Text & "','" & TextEdit3.Text & "','" & TextEdit4.Text & "','" & TextEdit5.Text & "','" & TextEdit6.Text & "','" & TextEdit7.Text & "','" & status & "','" & LookUpEdit1.Text & "','" & LookUpEdit2.Text & "','" & cost & "')", Con)
           ra = cmd.ExecuteNonQuery()
           Con.Close()

           MsgBox("CATEGORY ADDED", MsgBoxStyle.Information, "RECORD ADDED=" & ra)


       Catch ex As Exception
           MsgBox("not added", MsgBoxStyle.Critical)

       End Try



its not storing in my database
how can i clear this error
Posted
Comments
♥…ЯҠ…♥ 30-Dec-13 3:12am    
Where and what error you are getting?
Aarti Meswania 30-Dec-13 3:54am    
not enough info. provided, debug and check which exception you are getting?
shakeer mp 30-Dec-13 5:17am    
The values is not storing in my database

Don't you think you should define destination fields?

SQL
INSERT INTO TableName (Field1, Field2, Field3)
VALUES('Value1', Value2, 'Value3')
 
Share this answer
 
is requred in vb.net that destination is required
 
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