|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ASP.Net/VB.Net - Please check for nullreferenceexception
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim p As Integer Dim tday As Date tday = Today() Dim cmdstring As String = " select * from hitno where date = '" & tday & "'" Dim conn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\testdata.mdf;Integrated Security=True;User Instance=True;") Dim cmd = New SqlCommand(cmdstring, conn) conn.Open() p = cmd.ExecuteNonQuery() MsgBox(p) End Sub Which statement making nullreference please help me out. in the local machine it works but in the server it returns nullreferenceerror. |
|
#2
|
||||
|
||||
|
You cant have query's result in an integer variable.
If you want to read values from a query, you can read it in a datareader. Here is an example in this link http://www.startvbdotnet.com/ado/sqlserver.aspx And please wrap your code with code tags while posting code here, select all code and press # |
|
#3
|
|||
|
|||
|
Need help
When I write the code in my pc it works but if I put in in web server it says Nullreference. May I have your help please
code is as below Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Dim p As Integer Dim tday As Date tday = Today() Dim cmdstring As String = " select * from hitno2 where date = '" & tday & "'" Dim conn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\testdata.mdf;Integrated Security=True;User Instance=True") Dim cmd = New SqlCommand(cmdstring, conn) conn.Open() p = cmd.ExecuteNonQuery() MsgBox(p) End Sub end of code in the server the connectionstring is "provider = SQLNCLI;Data Source=localhost;initial catalo=testdata;user id =myuid ; password = mypassword;" Please help me |
|
#4
|
||||
|
||||
|
You made a similar thread here
http://forums.aspfree.com/net-devel...ion-306413.html You could have posted there itself. I wonder if you even looked at my response in that thread ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > ASP.Net/VB.Net - Please check for nullreferenceexception |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|