943,833 Members | Top Members by Rank

Ad:
Jun 2nd, 2009
0

SQL DataSet Exception

Expand Post »
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:
VB Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 18
Solved Threads: 2
Light Poster
killdude69 is offline Offline
45 posts
since Jul 2008
Jun 2nd, 2009
0

Re: SQL DataSet Exception

Wrong forum, you need the dot net forum...
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Jun 2nd, 2009
0

Re: SQL DataSet Exception

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.
Reputation Points: 18
Solved Threads: 2
Light Poster
killdude69 is offline Offline
45 posts
since Jul 2008
Jun 3rd, 2009
0

Re: SQL DataSet Exception

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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Find Average of 4 numbers
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Problem in reading Outlook Express DBX files ...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC