MarioRammy
Member
- Joined
- Feb 1, 2008
- Messages
- 12
- Programming Experience
- Beginner
Hi i've managed to get my VB.net app inserting into the SQL Server Database, the only problem is it only does it once and then does not move to the next roll. The second time i click the button it simply gives me the pop up box but no change to the database happens.
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
'Dim ra As Integer
'integer holds the number of records inserted
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strName11 As String
Dim strName12 As String
strName11 = txt1.Text
strName12 = txt2.text
myConnection = New SqlConnection("Data Source=.server=;db=Database1 ")
myConnection.Open()
myCommand = New SqlCommand("Insert into Table1 (Field1) values ('" & strName11 & "')", myConnection)
myCommand.ExecuteNonQuery()
MessageBox.Show("New Row Inserted") & ra)
strName11 = ""
myConnection.Close()
Me.Hide()
form2.show()
End Sub
End Class
Any idea's?
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
'Dim ra As Integer
'integer holds the number of records inserted
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strName11 As String
Dim strName12 As String
strName11 = txt1.Text
strName12 = txt2.text
myConnection = New SqlConnection("Data Source=.server=;db=Database1 ")
myConnection.Open()
myCommand = New SqlCommand("Insert into Table1 (Field1) values ('" & strName11 & "')", myConnection)
myCommand.ExecuteNonQuery()
MessageBox.Show("New Row Inserted") & ra)
strName11 = ""
myConnection.Close()
Me.Hide()
form2.show()
End Sub
End Class
Any idea's?