Problem in SQL Server 2005 using ASP.Net

Posted by megala on Stack Overflow See other posts from Stack Overflow or by megala
Published on 2010-03-09T05:26:40Z Indexed on 2010/03/09 5:36 UTC
Read the original article Hit count: 350

Filed under:

I created one ASP.Net project using SQLServer database as back end.I shows the foollwing 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.

© Stack Overflow or respective owner

Related posts about sql-server-2005