SQL DataSet Exception

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jul 2008
Posts: 45
Reputation: killdude69 is an unknown quantity at this point 
Solved Threads: 1
killdude69 killdude69 is offline Offline
Light Poster

SQL DataSet Exception

 
0
  #1
Jun 2nd, 2009
I am helping a friend with a project in Visual Basic, it is a program that uses a SQL database. There are some rows in the database, we can review them just fine. So the SELECT quesries are fine, it is the INSERT queries that we are having problems with.

We keep getting an exception when we try to insert data into the database when the "Finish" button is clicked. And if you press the continue button on the exception dialog, and then you press finish again, you get a different exception.

Exception from the first attempt

System.ArgumentException: No mapping exists from DbType Object to a known SqlDbType.
at System.Data.SqlServerCe.SqlCeType.FromDbType(DbType type)
at System.Data.SqlServerCe.SqlCeParameter.set_DbType(DbType value)
at WindowsApplication1.usersDataSetTableAdapters.UsersTableAdapter.InitCommandCollection()
at WindowsApplication1.usersDataSetTableAdapters.UsersTableAdapter.get_CommandCollection()
at WindowsApplication1.usersDataSetTableAdapters.UsersTableAdapter.Name(String name1)

Pressed "Continue"

Exception from the second attempt
System.NullReferenceException: Object reference not set to an instance of an object.
at WindowsApplication1.usersDataSetTableAdapters.UsersTableAdapter.Name(String name1)


Here is the code around the area that throws the exception:
  1. Function GetUserName() As String
  2. If TypeOf My.User.CurrentPrincipal Is _
  3. Security.Principal.WindowsPrincipal Then
  4. ' The application is using Windows authentication.
  5. ' The name format is DOMAIN\USERNAME.
  6. Dim parts() As String = Split(My.User.Name, "\")
  7. Dim username As String = parts(1)
  8. Return username
  9. Else
  10. ' The application is using custom authentication.
  11. Return My.User.Name
  12. End If
  13. End Function
  14. Public username As String = GetUserName()
  15. Dim usersTableAdapter As New usersDataSetTableAdapters.UsersTableAdapter()
  16. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  17. name = (Form1.TextBox1.Text + " " + Form1.TextBox2.Text + " " + Form1.TextBox4.Text)
  18. usersTableAdapter.Name(name)
  19. usersTableAdapter.Attention(Form1.ComboBox1.Text, name)
  20. usersTableAdapter.At_Ease(Form1.ComboBox2.Text, name)
  21. usersTableAdapter.Hand_Salute(Form1.ComboBox3.Text, name)
  22. usersTableAdapter.Present_Arms(Form1.ComboBox4.Text, name)
  23. usersTableAdapter.Order_Arms(Form1.ComboBox5.Text, name)
  24. usersTableAdapter.Rest(Form1.ComboBox6.Text, name)
  25. usersTableAdapter.About_Face(Form1.ComboBox7.Text, name)
  26. usersTableAdapter.Right_Face(Form1.ComboBox8.Text, name)
  27. usersTableAdapter.Left_Face(Form1.ComboBox13.Text, name)
  28. usersTableAdapter.Eyes_Right(Form1.ComboBox14.Text, name)
  29. usersTableAdapter.Ready_Front(Form1.ComboBox15.Text, name)
  30. usersTableAdapter.Forward_March(Form3.ComboBox1.Text, name)
  31. usersTableAdapter.Quick_Time(Form3.ComboBox2.Text, name)
  32. usersTableAdapter.Double_Time(Form3.ComboBox3.Text, name)
  33. usersTableAdapter.Mark_Time(Form3.ComboBox4.Text, name)
  34. usersTableAdapter.Half_Step(Form3.ComboBox13.Text, name)
  35. usersTableAdapter.Halt(Form3.ComboBox5.Text, name)
  36. usersTableAdapter.Right_Step(Form3.ComboBox6.Text, name)
  37. usersTableAdapter.Left_Step(Form3.ComboBox7.Text, name)
  38. usersTableAdapter.Change_Step(Form3.ComboBox8.Text, name)
  39. usersTableAdapter.To_The_Rear(Form3.ComboBox14.Text, name)
  40. usersTableAdapter.Right_Flank(Form3.ComboBox9.Text, name)
  41. usersTableAdapter.Left_Flank(Form3.ComboBox10.Text, name)
  42. usersTableAdapter.Rout_Step(Form3.ComboBox11.Text, name)
  43. usersTableAdapter.Parade_Rest(Form3.ComboBox12.Text, name)
  44.  
  45. End Sub

Does anyone know what could be causing this? Because I am completely clueless.
Last edited by killdude69; Jun 2nd, 2009 at 9:33 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 894
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: SQL DataSet Exception

 
0
  #2
Jun 2nd, 2009
Wrong forum, you need the dot net forum...
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 45
Reputation: killdude69 is an unknown quantity at this point 
Solved Threads: 1
killdude69 killdude69 is offline Offline
Light Poster

Re: SQL DataSet Exception

 
0
  #3
Jun 2nd, 2009
I was looking for it, but I couldn't really find it. Sorry. I guess I could have tried harder to find it. But eh, close enough, right? Anyways, the problem has actually been solved, I just can't figure out how to delete the thread. Because marking it as solved would keep it here.

This forum doesn't have the same thread tool setup as other vBulletin forums.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 894
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: SQL DataSet Exception

 
0
  #4
Jun 3rd, 2009
Well for future reference...

The C#.NET forum on this site is...

http://www.daniweb.com/forums/forum61.html

and the VB.NET forum is...

http://www.daniweb.com/forums/forum58.html

and perhaps PMing a MOD might solve the other problem...

Glad you got it solved...

Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC