|
hi im kind of a rookie in vb .net and im trying to write somthing to my dataset (keep in mind that as is only for knowing the lenguage i using an acces database), i dont have any error in the intellitype screen. but i have this exception on runtime "unable to cast object type from system.data.dataset to windows.application1.dataset
my codes is something like this.
Private Sub button1_click (.........) handles button1.click dim ds as cashierdataset (thats the name of the database) ds = cashierdatabase -------------------------------------------------------->here is the exception dim agregar as new cashierdataset.userrow agregar = ds.user.newuserrow (user is one of the datatables) agregar.user = CStg(textbox1.text) agregar.password = Cstg(textbox2.text) if ratiobutton1.cheked then agregar.allow = Cint(1) if ratiobutton2.cheked then agregar.allow = Cint(2)
ds.user.rows.add(agregrar)
end sub
when i run it it starts debugging but get the exception above in the line ds = cashierdataset the problem is if i dont declare that i cant use it to get the data in there....
| | hiperion Sunday, October 11, 2009 9:49 PM | that how you get data from your table or database: just modify it according your will
Using con As New OleDbConnection(cnn)
Dim name As New OleDbCommand("Select * From Table1 ", con)
con.Open()
Dim reader As OleDbDataReader = name.ExecuteReader()
With reader
If .HasRows Then
.Read()
Dim InterSql As Integer = .FieldCount
If Me.TextBox2.Text = .Item("StaffID").ToString Then
MsgBox(
"Welcome")
Dim form1 As New Form1
form1.Show()
Exit Sub
Else
MsgBox(
"The password not much", MsgBoxStyle.Exclamation, "Password")
Me.TextBox2.Clear()
Me.TextBox2.Focus()
Exit Sub
End If
End If
End With
MsgBox(
"The Name not much", MsgBoxStyle.Exclamation, "Name")
Me.TextBox1.Clear()
Me.TextBox1.Focus()
Exit Sub
End Using
Don't judge me, just Upgrade me. Thanks! - Marked As Answer byJeff ShanMSFT, ModeratorFriday, October 16, 2009 9:44 AM
-
| | Malange Sunday, October 11, 2009 9:55 PM | Hi hiperion, Here is a example about using access database, it provides several methods about how to create an access application. Hope this helps. http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/d863f226-247e-4317-b979-05199ba8b22d/Regards Jeff Shan
Please remember to mark the replies as answers if they help and unmark them if they provide no help. - Marked As Answer byJeff ShanMSFT, ModeratorFriday, October 16, 2009 9:44 AM
-
| | Jeff Shan Thursday, October 15, 2009 7:01 AM | that how you get data from your table or database: just modify it according your will
Using con As New OleDbConnection(cnn)
Dim name As New OleDbCommand("Select * From Table1 ", con)
con.Open()
Dim reader As OleDbDataReader = name.ExecuteReader()
With reader
If .HasRows Then
.Read()
Dim InterSql As Integer = .FieldCount
If Me.TextBox2.Text = .Item("StaffID").ToString Then
MsgBox(
"Welcome")
Dim form1 As New Form1
form1.Show()
Exit Sub
Else
MsgBox(
"The password not much", MsgBoxStyle.Exclamation, "Password")
Me.TextBox2.Clear()
Me.TextBox2.Focus()
Exit Sub
End If
End If
End With
MsgBox(
"The Name not much", MsgBoxStyle.Exclamation, "Name")
Me.TextBox1.Clear()
Me.TextBox1.Focus()
Exit Sub
End Using
Don't judge me, just Upgrade me. Thanks! - Marked As Answer byJeff ShanMSFT, ModeratorFriday, October 16, 2009 9:44 AM
-
| | Malange Sunday, October 11, 2009 9:55 PM | Hi hiperion, Here is a example about using access database, it provides several methods about how to create an access application. Hope this helps. http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/d863f226-247e-4317-b979-05199ba8b22d/Regards Jeff Shan
Please remember to mark the replies as answers if they help and unmark them if they provide no help. - Marked As Answer byJeff ShanMSFT, ModeratorFriday, October 16, 2009 9:44 AM
-
| | Jeff Shan Thursday, October 15, 2009 7:01 AM |
|