Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with my error
#1
my erro:

Value cannot be null.
Parameter name: dataSet

heres my code:

[code2=vbnet]Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click



Dim da As New MySqlDataAdapter("Update personalinfo, schoolinfo set sno = '" & txtSno.Text & "',
lastname = '" & txtLastName.Text & "',
middlename = '" & txtMiddleName.Text & "',
gender = '" & cmbGender.Text & "',
dateofbirth = '" & txtBirthday.Text & "',
school = '" & txtCollege.Text & "',
course = '" & cmbCourse.Text & "',
department = '" & txtDepartment.Text & "',
dateenrolled = '" & txtEnrolled.Text & "',
yeargraduated = '" & txtGraduated.Text & "',
where no = '" & txtSno.Text & "'", MySQLConn)

da.Fill(ds)
Me.Hide()

frmMain.showData()[/code2]

im trying to edit and save the info here.. the error appears above.
#2
Is the error being produced on this line?
[code2=vbnet]da.Fill(ds)[/code2]

If so, where do you create ds? Where exactly is the error being thrown?
My Blog | My Setup | My Videos | Have a wonderful day.
#3
yes its on that line

the error is:

ArgumentNullException was unhandled,
Valu Cannot be null. Parameter name: dataSet


i initialize the ds at the top before the
public class frmEdit
like this

Code:
Public Class frmEdit


    Dim MySQLConn As MySqlConnection
    Dim da As MySqlDataAdapter
    Dim ds As DataSet
#4
Well, just as the error message says
Value Cannot be null. Parameter name: dataSet

When you create a variable of any sort of object, the variable is defaulted to a value of null. So, you need to assign a value to ds. Something like this, perhaps:
[code2=vbnet]Dim MySQLConn As MySqlConnection
Dim da As MySqlDataAdapter
Dim ds As DataSet = New DataSet("newDataSet")[/code2]
My Blog | My Setup | My Videos | Have a wonderful day.
#5
when i did that another error occured.

InvalidOperationException was unhandled
Fill:SelectCommand.Connection property has not been initialized.

the same place where the error occured in ds
#6
This is because somewhere in your code you must specify that
[code2=vbnet]da.Connection = MySQLConn[/code2]

However, this will also throw an error, so you must also change
this
[code2=vbnet]Dim MySQLConn As MySqlConnection[/code2]
to this:
[code2=vbnet]Dim MySQLConn As MySqlConnection = New MySqlConnection[/code2]
My Blog | My Setup | My Videos | Have a wonderful day.
#7
but i already have this.
in the save button?
Code:
Dim da As New MySqlDataAdapter("Update personalinfo, schoolinfo set sno = '" & txtSno.Text & "',
lastname = '" & txtLastName.Text & "',
middlename = '" & txtMiddleName.Text & "',
gender = '" & cmbGender.Text & "',
dateofbirth = '" & txtBirthday.Text & "',
school = '" & txtCollege.Text & "',
course = '" & cmbCourse.Text & "',
department = '" & txtDepartment.Text & "',
dateenrolled = '" & txtEnrolled.Text & "',
yeargraduated = '" & txtGraduated.Text & "',
where no = '" & txtSno.Text & "'", MySQLConn)
#8
Ah okay, I simply overlooked that! Sorry!

Hmm.

Well, with your current code, you are creating an adapter and you are sending in your Command Text and Connection variables via the parameters. However, I believe that this error is occurring because you do not actually have a MySqlCommand variable. Try revising your code so it contains a MySqlCommand variable (And be sure to link it to the connection), as such:

[code2=vbnet]Dim commandText As String = "Update personalinfo, schoolinfo set sno = '" & txtSno.Text & "', lastname = '" & txtLastName.Text & "', middlename = '" & txtMiddleName.Text & "', gender = '" & cmbGender.Text & "', dateofbirth = '" & txtBirthday.Text & "', school = '" & txtCollege.Text & "', course = '" & cmbCourse.Text & "', department = '" & txtDepartment.Text & "', dateenrolled = '" & txtEnrolled.Text & "', yeargraduated = '" & txtGraduated.Text & "', where no = '" & txtSno.Text & "'"

Dim MySQLConn As MySqlConnection = New MySqlConnection
Dim MySQLComm As MySqlCommand = New MySqlCommand(commandText, MySQLConn)
Dim da As MySqlDataAdapter
Dim ds As DataSet = New DataSet("newDataSet")

da = New MySqlDataAdapter(MySQLComm)[/code2]

This should resolve your problem. I have never actually tried connecting to a MySQL Server using the method that you are using, so I apologize if I am incorrect on the matter.
My Blog | My Setup | My Videos | Have a wonderful day.
#9
i think i am too late to help you
Support me by take tour to BPForums http://bit.ly/YTBCS1

Get More Views on youtubehttp://addm.cc/?WIZ01V


Possibly Related Threads…
Thread Author Replies Views Last Post
  TwitterAPIException - Error TwitterVB Crammer 3 14,514 10-14-2012, 09:06 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)