Imports System.Data
Imports System.Data.SqlClient
< br />Public Class frmAddMovie
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim conString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ Movies.mdf;Integrated Security=True;User Instance=True;"
Dim con As New SqlConnection(conString)
Dim cmd As New SqlCommand("Insert Into tblMovies(fldTitle, fldDirector, fldRating)Values( 'Solar Babies','PG','Rick Flair')", con)
Using con
con.Open()
cmd.ExecuteNonQuery()
End Using
If MessageBox.Show("Movi e Added") = Windows.Forms.DialogResult.OK Then
Me.Close()
End If
End Sub
End Class
div>
I run on Snow Leopard and access VS2010 from my mac from time to time. I have a similar problem on the VM but when using the same code, it runs fine.
p>
I’m not sure if this is the problem, but the solution is to try it on a Windows-based PC. If it works, then at least you know it is related to a virtual machine.
p>
I am trying to connect to SQL Server Express locally using VB.NET 2005. I directly extracted my connection string from the app.config file. When I run, I get a NO error and the connection status returns Open, but the command is not processed.
Imports System.Data
Imports System.Data.SqlClient
Public Class frmAddMovie
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim conString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security =True;User Instance=True;"
Dim con As New SqlConnection(conString)
Dim cmd As New SqlCommand("Insert Into tblMovies(fldTitle, fldDirector, fldRating)Values('Solar Babies', ' PG','Rick Flair')", con)
Using con
con.Open()
cmd.ExecuteNonQuery()
End Using
If MessageBox.Show("Movie Added") = Windows.Forms .DialogResult.OK Then
Me.Close()
End If
End Sub
End Class
Are you running in a virtual machine?
I run on Snow Leopard and access VS2010 from my mac from time to time. I have a similar problem on the VM but when using the same code, it runs fine.
p>
I’m not sure if this is the problem, but the solution is to try it on a Windows-based PC. If it works, then at least you know it is related to a virtual machine.