VB.NET 2005 is connected to SQL Server Express, there is no error, but CMDS does not run

I am trying to use VB.NET 2005 to connect to SQL Server Express locally. I directly extracted my connection string from the app.config file. When I run it, I get NO error and the connection status returned to open, but the command was not processed.

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

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.

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.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3373 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.