Hi,
there, I need help with the connection string . An error saying 'Object reference not set to an instance of an object.'
Can be seen when i make the system to run. It effects the code below:
[B]Dim str As String = ConfigurationManager.ConnectionStrings("CourierSystemConnectionString").ConnectionString[/B]
Partial Class _Default
Inherits System.Web.UI.Page
[B]Dim str As String = ConfigurationManager.ConnectionStrings("CourierSystemConnectionString").ConnectionString[/B] 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 = "student" Then
sql = "select StaffID, Password from StaffRegis_Table where uname='" + tuname.Text + "' and upass='" + tupass.Text + "'"
Else
sql = "select StaffID, Password from StaffRegis_Table 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 = "student" Then
Session("ses_dname") = rdr("sfname") + " " + rdr("slname")
Session("ses_uid") = rdr("sid")
Response.Redirect("mypage.aspx")
Else
Session("ses_dname") = rdr("stffname") + " " + rdr("stflname")
Session("ses_uid") = rdr("stfid")
Session("ses_utype") = rdr("utype")
Response.Redirect("index.aspx")
End If
End If
End Sub
End Class