Click here to Skip to main content
16,017,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
MY SQL TABLE,
Table name Login.

column Name    Datatype

Username        varchar(10)	
Password	nchar(10)

/* source code */	

con.Open()
       str = "select * from login where Username='" & UnameTextBox.Text & "' and Password='" & UPassword.Text & "' "
       cmd = New SqlCommand(str, con)
       da = New SqlDataAdapter(str, con)
       da.Fill(dt)
       If dt.Rows.Count <> 0 Then
           Response.Redirect("SelectBranch.aspx")
       Else
           MsgBox("is not match")

           cmd.ExecuteNonQuery()


       End If
       con.Close()

Run time:

Error message is "Value cannot be null. Parameter name: dataTable"
Posted
Comments
Varun Sareen 17-Feb-12 2:01am    
Are you initializing the datatable? Please provide some more clarity into it.

If you're error pops up on the line da.Fill(dt) it's telling you that you didn't create a DataTable object. You're passing in Nothing instead of an instance of a DataTable.

You didn't provide the code that declared dt, so it's impossible to say for sure.

Perhaps you did this:
Dim dt As DataTable


instead of this:
Dim dt As New DataTable
 
Share this answer
 
Comments
Ravi chandran from thanjavur 17-Feb-12 22:01pm    
thanks
Ravi chandran from thanjavur 17-Feb-12 22:08pm    
i have created DataTable object. Again the Same error please help me.
Dave Kreskowiak 17-Feb-12 23:05pm    
Again, you haven't shown us the ENTIRE code that is around the line where the error occurs nor have you told us on which line it occurs.
VB
Dim str As String
            str = "select * from login where Username='" & UnameTextBox.Text & "' and Password='" & UPassword.Text & "' "
            Dim da As New SqlDataAdapter(str, con)
            Dim ds As New DataSet
            da.Fill(ds, "login")

if dt.rows.cont<>o then
 Response.Redirect("SelectBranch.aspx")
       Else
           MsgBox("is not match")
            cmd.ExecuteNonQuery()
        End If



I hope this will help for you

please also give me reply what happens.......
 
Share this answer
 
You are passing the string command to sqldataadapter. Insted of that you can pass the sqlcommand alone to it. And that execute non query is not needed. I think this will be your problem.
 
Share this answer
 
Comments
Member 13258186 9-Jul-17 20:58pm    
Using mail As New MailMessage
mail.From = New MailAddress("admissioncsabnic@gmail.com")
mail.To.Add(destination.Text$)
mail.Body = lblname.Text$
'If Not OpenFileDialog1.FileName = vbNullString Then
'Dim attach As New Attachment()
Dim attach As New System.Net.Mail.Attachment(profilepic1.ImageLocation)
'MyMailMessage.Attachments.Add(attchm)
mail.Attachments.Add(attach)
'End If
mail.Subject = lblname.Text$
mail.Priority = mail.Priority.Normal
Using SMTP As New SmtpClient
'SMTP.EnableSsl = True
'SMTP.Port = "587"
'SMTP.Host = "smtp.gmail.com"
'SMTP.Credentials = New Net.NetworkCredential("ujjawal.vermanu53@gmail.com", "bholenath1994")
'SMTP.Send(mail)

SMTP.Host = "smtp.gmail.com"
SMTP.EnableSsl = True
Dim NetworkCred As NetworkCredential = New NetworkCredential("admissioncsabnic@gmail.com", "sachin@6")
SMTP.UseDefaultCredentials = True
SMTP.Credentials = NetworkCred
SMTP.Port = 587
SMTP.Send(mail)
End Using
End Using

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900