Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27333

VB.NET connectiing to SQL 2008- SQLException was unhandled

$
0
0
Here is my issue: This is my error. SQLException was unhandled. Below is the code. I know the info is right for SQL. Any thoughts:
Code:

Dim Conn As SqlConnection = New SqlConnection("Data source=MY DATASOURCE\SQL_NEW;Database=MY DATABASE;Integrated Security=True")
        Dim objcommand As SqlCommand = New SqlCommand
        With objcommand
            .Connection = Conn
            .CommandText = "Insert into MY_TABLE" & _
          "(NAME,PHONE,ID)" & _
          "VALUES (NAME,PHONE,ID)"
          .Parameters.AddWithValue("@NAME", NAME)
          .Parameters.AddWithValue("@PHONE", PHONE)
          .Parameters.AddWithValue("@ID", ID)
        End With
        Try
        Conn.Open()

        objcommand.ExecuteNonQuery()
        Catch(ex as SqlException)
          MessageBox.Show(ex.Message.ToString(), "Error Message")
        End Try
        End


Viewing all articles
Browse latest Browse all 27333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>