Showing posts with label netwhen. Show all posts
Showing posts with label netwhen. Show all posts

Wednesday, March 21, 2012

help -Object reference not set to an instance of an object.

i m new for asp.net

when i run app. i got this error,

-----
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 49:
Line 50: adpt.Fill(ds, "SMS_student_class_master")
Line 51: txt.Text = ds.Tables.Item("roll_no").ToString
Line 52: con.Close()
Line 53: End Sub

Source File: c:\inetpub\wwwroot\aspnet\sms\assignment_d.aspx.vb Line: 51
------

my source code given below,

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsNothing(Request.QueryString("id")) Then
sid = Request.QueryString("id")
End If
Dim con As New SqlConnection
Dim constr As String
Dim cmd As New SqlCommand
Dim ds As New DataSet
Dim adpt As New SqlDataAdapter

constr = "data source=Baroda;user id=sa;password=;" & _
"initial catalog=SMS;persist security info=False;workstation id=Baroda;Packet size=4096"
con.ConnectionString = constr
con.Open()

cmd.CommandText = "SELECT * FROM SMS_student_class_master WHERE " & _
"stud_id='" + sid + "'"
cmd.Connection = con
adpt.SelectCommand = cmd

adpt.Fill(ds, "SMS_student_class_master")
txt.Text = ds.Tables.Item("roll_no").ToString
con.Close()
End Sub
---

what should i do?
anyone have any idea?
plz give solution.
its urgent.

thanks in advance.cmd.Connection = con
adpt = new SqlDataAdapter(cmd)
adpt.Fill(...)

Friday, February 24, 2012

help me understand how to move the express database to live

im using the the login controls with asp.net

when i test locally everything works great, its see the ASPNETDB.MDF file, checks the login info and passes the user on to the next page.

However when i move the application to the live server it fails, it cant find the datasource that contains users/password etc. here is there error:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

So im missing something here, im used to connecting directly to a remote SQL database and accessing the info from there.

Can someone point me in the right direction? Can the MDF file not be used off the server itself without SQL express installed? Do i need to migrate those tables into a real SQL database?

Thanks,
Sean

update:

installed SQL express on the webserver and it seems to work better now.

I dont get the same error however the user can not login, each time i get "invalid login etc".

If i use the local debug mode it will login correctly.

:(

Any ideas where i need to look?|||

still no luck with this.

can anyone help me understand the process of moving a sql express DB to a production enviroment with SQL Server 2000?