MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




problem in vb code...

This is a discussion on problem in vb code... within the MapPoint Desktop Discussion forums, part of the Map Forums category; will u please check it out this code n try to hep me ...out .. error occurred is : ":Column ...


Go Back   MapPoint Forums > Map Forums > MapPoint Desktop Discussion

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-21-2009
Junior Member
White Belt
 
Join Date: Jun 2009
Posts: 1
problem in vb code...

will u please check it out this code n try to hep me ...out ..
error occurred is : ":Column name or number of supplied values does not match table definition."

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.Click
Dim con_str As String = "Data Source=.\SQLEXPRESS;Initial Catalog=mydatabase;Integrated Security=True;Pooling=False"
Dim cn As New SqlConnection(con_str)
Dim cmd As New SqlCommand()
cmd.CommandText = "select * from tabreg "
cmd.Connection = cn
Dim dd As New SqlDataAdapter(cmd)
Dim dst As New DataSet()
dd.Fill(dst, "first")
Dim dt As DataTable = dst.Tables("first")
Dim n As Integer = dt.Rows.Count
Dim p As Integer = 1001
If n > 0 Then
Dim z As Integer
For z = 0 To n - 1
Dim dr As DataRow = dt.Rows(z)
p = dr("regno")
Next
p = p + 1
End If
cmd = New SqlCommand()
cmd.CommandText = "insert into tabreg values(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13, @14,@15,@16,@17,@18,@19,@20,@21,@22,@23,@24,@25,@2 6,@27,@28,@29,@30,@31,@32,@33,@34,@35,@36,@37)"
cmd.Connection = cn
cmd.Parameters.AddWithValue("@1", p)
cmd.Parameters.AddWithValue("@2", t1.Text)
cmd.Parameters.AddWithValue("@3", t2.Text)
cmd.Parameters.AddWithValue("@4", t3.Text)
cmd.Parameters.AddWithValue("@5", t4.Text)
cmd.Parameters.AddWithValue("@6", t5.Text)
Dim g As String = "male"
If (r2.Checked) Then
g = "female"
End If
cmd.Parameters.AddWithValue("@7", g)
cmd.Parameters.AddWithValue("@8", Val(t6.Text))
Dim h As String = "married"
If (r4.Checked) Then
h = "unmarried"
End If
cmd.Parameters.AddWithValue("@9", h)
Dim nation As String = ""
nation = nation & c1.SelectedValue
cmd.Parameters.AddWithValue("@10", nation)


Dim MinDate As Date
Dim dob As Date
MinDate = CDate("1.1.1980")
dob = CDate(mt1.Text)
' Check that dob is between MinDate and Now()
If MinDate <= dob AndAlso dob <= System.DateTime.Now Then
' Dob is valid
Else
' Dob is outside date bounds
End If

cmd.Parameters.AddWithValue("@11", dob)
Dim i As String = "ST"
If (r6.Checked) Then
i = "SC"
End If
If (r7.Checked) Then
i = "OBC"
End If
If (r8.Checked) Then
i = "GEN"
End If
cmd.Parameters.AddWithValue("@12", i)


cmd.Parameters.AddWithValue("@13", t7.Text)
cmd.Parameters.AddWithValue("@14", t8.Text)
cmd.Parameters.AddWithValue("@15", t9.Text)

Dim hint As String = ""
hint = hint & c2.SelectedValue
cmd.Parameters.AddWithValue("@16", hint)


cmd.Parameters.AddWithValue("@17", t11.Text)
cmd.Parameters.AddWithValue("@18", t12.Text)
cmd.Parameters.AddWithValue("@19", t13.Text)
cmd.Parameters.AddWithValue("@20", mt2.Text)
cmd.Parameters.AddWithValue("@21", t14.Text)

cmd.Parameters.AddWithValue("@22", t15.Text)
cmd.Parameters.AddWithValue("@23", t16.Text)
cmd.Parameters.AddWithValue("@24", t17.Text)
cmd.Parameters.AddWithValue("@25", mt3.Text)

Dim nation_p As String = ""
nation_p = nation_p & c3.SelectedValue
cmd.Parameters.AddWithValue("@26", nation_p)


cmd.Parameters.AddWithValue("@27", t18.Text)
cmd.Parameters.AddWithValue("@28", t19.Text)
cmd.Parameters.AddWithValue("@29", t20.Text)
cmd.Parameters.AddWithValue("@30", mt4.Text)

Dim nation_t As String = ""
nation_t = nation_t & c4.SelectedValue
cmd.Parameters.AddWithValue("@31", nation_t)


cmd.Parameters.AddWithValue("@32", rt1.Text)
cmd.Parameters.AddWithValue("@33", rt2.Text)


cmd.Parameters.AddWithValue("@34", Val(t21.Text))
cmd.Parameters.AddWithValue("@35", Val(t22.Text))
cmd.Parameters.AddWithValue("@36", Val(t23.Text))
cmd.Parameters.AddWithValue("@37", rt3.Text)

dd = New SqlDataAdapter(cmd)
dst = New DataSet()
dd.Fill(dst)
MessageBox.Show("ur id is " & p.ToString)
End Sub


m waiting for ur help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 06-24-2009
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,308
Re: problem in vb code...

Hi,

Please start by stepping with your debugger. Then you can localize the offending line of code. Then if it has something to do with mappoint you can post again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 06-24-2009
Administrator
Green Belt
 
Join Date: Sep 2007
Posts: 106
Re: problem in vb code...

There seems to be a rash of newbie programmers with Indian-sounding names asking for basic help lately. Is there a way to make that sound less politically correct? I guess I'd worry about offending someone but I can't remember the last time I saw a "Bhatnagar" or "Kapoor" trying to be helpful and answer anyone's question.

Eric
__________________
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contribute and Learn at our New MapPoint and Virtual Earth Wiki - http://www.MapElves.com
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 06-25-2009
NickH
Yellow Belt
 
Join Date: Jun 2008
Location: Bromsgrove, UK
Posts: 21
Re: problem in vb code...

Don't you mean "Is there a way to make that sound less politically INcorrect?" ? It's probably just my cynical mind but I'd suspect a major project has been outsourced and the new team is learning on the job. No doubt promises were made about experience but the client was really only interested in the price.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 07-01-2009
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,308
Re: problem in vb code...

Hi,

No problem, but it is really impossible to read and debug a couple of hunderds line of code. That's up to you. Try to trace down the problem to the offending line, then simplify the code eventally and post again here.

Lots of people will try to help here but everyone has his own job and much to do.

I't like a marriage, effort must come from both ends
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 07-01-2009
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 3,418
Blog Entries: 3
Problem in Database Table

Just glancing at it I'm guessing the code used to work but someone modified the table... I doubt there's anything in that code that's wrong - to fix it you'd need access to the database table and compare to the code.

Eric
__________________
~ Now taking orders for MapPoint 2010 ~
~~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 07-01-2009
Eric Frost's Avatar
Senior Member
Black Belt
 
Join Date: Jul 1992
Posts: 3,418
Blog Entries: 3
Re: problem in vb code...

Oh - and no I meant what I said.
__________________
~ Now taking orders for MapPoint 2010 ~
~~
~ Upgrade to MapForums Plus membership ~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
code, problem


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
How to map zip code and postal code to mappoint Boon MapPoint Desktop Discussion 3 09-22-2009 05:39 PM
Mapping Areas based on Postal Code / Zip Code? toncm1 General Chat 4 05-30-2009 06:43 PM
Using zip code data, suppressing zip code labels? Santa Monica Realtor MapPoint Desktop Discussion 3 02-25-2009 10:54 AM
code problem mmartin MapPoint Desktop Discussion 1 04-10-2007 07:55 AM
Zip Code Problem Anonymous MapPoint Desktop Discussion 1 12-07-2003 10:50 PM


All times are GMT -5. The time now is 01:27 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
MP2K Magazine
Visitor Map



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67