hi there,
i need help in my vb behind codes. There is an error at these part 'con.Open()'. When i run the code the error says, "The ConnectionString property has not been initialized.". It also says , "invalid operationsException was unhandled by user code."
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Web
Partial Class _Default
Inherits System.Web.UI.Page
Dim str As String = ConfigurationManager.AppSettings("Web2.Config")
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim rdr As SqlDataReader
Dim sql As String
Dim t As String
Protected Sub btnlogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnlogin.Click
con = New SqlConnection(str)
con.Open()
Dim type As String
type = ddltype.SelectedValue
If type = "Customer" Then
sql = "select CusID, Password2 from Customer_Regis where uname='" + tuname.Text + "' and upass='" + tupass.Text + "'"
ElseIf type = "Delivery Boy" Then
sql = "select DelID, Password1 from DeliveryBoy_Regis where uname='" + tuname.Text + "' and upass='" + tupass.Text + "'"
Else
sql = "select ManID, Password from Manager_Regis where uname='" + tuname.Text + "' and upass='" + tupass.Text + "'"
End If
cmd = New SqlCommand(sql, con)
rdr = cmd.ExecuteReader
If rdr.Read Then
If ddltype.SelectedValue = "Customer" Then
Session("ses_dname") = rdr("CusFName") + " " + rdr("CusLName")
Session("ses_uid") = rdr("CusID")
Response.Redirect("mypage.aspx")
ElseIf ddltype.SelectedValue = "Delivery Boy" Then
Session("ses_dname") = rdr("DelFName") + " " + rdr("DelLName")
Session("ses_uid") = rdr("DelID")
Session("ses_utype") = rdr("Designation")
Response.Redirect("index.aspx")
Else
Session("ses_dname") = rdr("ManFName") + " " + rdr("ManLName")
Session("ses_uid") = rdr("ManID")
Session("ses_utype") = rdr("Designation")
Response.Redirect("default2.aspx")
End If
End If
End Sub
Protected Sub ddltype_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddltype.SelectedIndexChanged
End Sub
End Class