I created one ASP.Net project using SQL Server database as back end. I shows the following error. How to solve this?
===============Coding
Imports System.Data.SqlClient
Partial Class Default2
Inherits System.Web.UI.Page
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim ra As Integer
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
myConnection = New SqlConnection("Data Source=JANANI-FF079747\SQLEXPRESS;Initial Catalog=new;Persist Security Info=True;User ID=sa;Password=janani") 'server=localhost;uid=sa;pwd=;database=pubs")
myConnection.Open()
myCommand = New SqlCommand("Insert into table3 values 'janani','jan'")
ra = myCommand.ExecuteNonQuery() ========---> error is showing here
MsgBox("New Row Inserted" & ra)
myConnection.Close()
End Sub
End Class
=========Error Message============
ExecuteNonQuery: Connection property has not been initialized.