 |
| Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book:
Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 3rd, 2007, 05:32 AM
|
|
Registered User
|
|
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Problem with adding rows to database
Hi! I'm a newbie in visual basic, learning actually. Now, I'm working on a project application which manages data of a prison network (prisoners, employees, prisons etc.). I have managed to create the database, forms for adding and viewing etc. The Viewing works fine, I can read everything from the database, but now I stumbled upon the adding problem. I've created a module which consists of functions which later are called to get, add or update data (rows). The get function works fine like I said but with add function i get this weird error:
Overload resolution failed because no accessible "AddZaposlenikRow" accepts this number of arguments.
I've googled all night, stumbled upon many problems with same error but nothing to with mine...now maybe my brain is cooked from the night work but I'm not sure what else should I try. I would appreciate any solution, advice etc.
This is the code:
Code:
Public Function AddZaposlenik(ByVal UserID As Integer, ByVal NewZaposlenik As Zaposlenik) As _
Boolean
Dim AddZaposlenikAdapter As New ZatvorDataSetTableAdapters.ZaposlenikTableAdapter
Dim AddZaposlenikTable As New ZatvorDataSet.ZaposlenikDataTable
AddZaposlenikAdapter.Fill(AddZaposlenikTable)
Dim GetUserAdapter As New ZatvorDataSetTableAdapters.UserTableAdapter
Dim GetUserTable As New ZatvorDataSet.UserDataTable
GetUserAdapter.Fill(GetUserTable)
Dim MyRows() As ZatvorDataSet.UserRow = CType(GetUserTable.Select("UserID = " & _
UserID.ToString), ZatvorDataSet.UserRow())
If MyRows.Length > 0 Then
With NewZaposlenik
AddZaposlenikTable.AddZaposlenikRow(MyRows(0), .ZaposlenikIme, .ZaposlenikPrezime, .ZaposlenikJMBG) (this is where the error appears)
End With
AddZaposlenikAdapter.Update(AddZaposlenikTable)
Else
Return False
End If
Return True
End Function
End With
ZaposlenikAdapter.Update(ZaposlenikTable)
Else
Return False
End If
Return True
End Function
P.S. I'm from Croatia so I hope expressions like zaposlenik(employee) won't confuse you
[u]</u>
|
|

September 4th, 2007, 10:58 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
This line
Code:
. . .
With NewZaposlenik
AddZaposlenikTable.AddZaposlenikRow( . . .
Is that actually a method of the ZatvorDataSet.ZaposlenikDataTable?
What is/are the signature(s) that show in the intelliSense for the method?
(BTW: if you bracket your code at this forum with [ code] . . . [ /code] {minus the spaces} that part will be fixed-space font. That can make postings easier to read.)
|
|

September 4th, 2007, 03:49 PM
|
|
Registered User
|
|
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sorry for the code and thanks for the heads up. only now I noticed the insert code button...:D
anyway, intelliSense pops the AddZaposlenikRow. here is the picture:
http://img117.imageshack.us/img117/3305/databaseog9.png
|
|

September 9th, 2007, 07:05 AM
|
|
Registered User
|
|
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
does anybody know what I'm doing wrong?
I have tried everything in my knowledge but can't come up still an answer...
Since I'm a beginner, I've gone through the Wrox book VB 2005 beginners start edition kit. I've worked through all the exercises and managed to build the personal organizer in the book.
Now I took the book as a reference to my project, and since it didn't worked my way I tried the similar example form the book but with minor adjustments to the code...with no success. To tell you the truth I quite don't understand why the error occurs when even Intellisense gives me the method AddZaposlenikRow...
Could anyone explain at least the error...for instance, in which cases it appears? why it brings up the number of arguments? do the arguments refer to the columns in the dataset, or properties in Zaposlenik class, or both? any kind of advice which could point me in the right direction, so i could understand the error and then I could continue on by myself.
|
|

September 13th, 2007, 05:10 PM
|
|
Registered User
|
|
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have found the solution yesterday night....actually it's dumb error by my n00b self..:D. I'll post the solution so if anybody stumbles on the same issue.
Now what happened...in short I was making an application which should be a prison data management system. You have entities prisons, sectors, headmasters, prisoners, employees, and users table. Now I posted on this forum code which was related to the employees adding. The error which was occuring "Overload resolution etc..." happened because of the foreign keys the employees contained (UserID,PriSonID, SectorID). In my code you can see the MyUserRow part..iI use it to see if there are any rows in te user table, if there are I can add rows to the employee table. Now since I have two more foreign keys I have to repeat the procedure with the other foreign keys which you can see in the code.
Code:
Public Function DodajZaposlenik(ByVal UserID As Integer, ByVal ZatvorID As Integer, _
ByVal SektorID As Integer, ByVal NewZaposlenik As Zaposlenik) As _
Boolean
Dim ZaposlenikAdapter As New ZatvorDataSetTableAdapters.ZaposlenikTableAdapter
Dim ZaposlenikTable As New ZatvorDataSet.ZaposlenikDataTable
ZaposlenikAdapter.Fill(ZaposlenikTable)
Dim GetUserAdapter As New ZatvorDataSetTableAdapters.UserTableAdapter
Dim GetUserTable As New ZatvorDataSet.UserDataTable
GetUserAdapter.Fill(GetUserTable)
Dim GetZatvorAdapter As New ZatvorDataSetTableAdapters.ZatvorTableAdapter
Dim GetZatvorTable As New ZatvorDataSet.ZatvorDataTable
GetZatvorAdapter.Fill(GetZatvorTable)
Dim GetSektorAdapter As New ZatvorDataSetTableAdapters.SektorTableAdapter
Dim GetSektorTable As New ZatvorDataSet.SektorDataTable
GetSektorAdapter.Fill(GetSektorTable)
Dim MyUserRow() As ZatvorDataSet.UserRow = CType(GetUserTable.Select("ID=" & _
UserID.ToString), ZatvorDataSet.UserRow())
Dim MyZatvorRow() As ZatvorDataSet.ZatvorRow = CType(GetZatvorTable.Select("ID=" & _
ZatvorID.ToString), ZatvorDataSet.ZatvorRow())
Dim MySektorRow() As ZatvorDataSet.SektorRow = CType(GetSektorTable.Select("ID=" & _
SektorID.ToString), ZatvorDataSet.SektorRow())
If MyUserRow.Length > 0 And MyZatvorRow.Length > 0 And MySektorRow.Length > 0 Then
With NewZaposlenik
ZaposlenikTable.AddZaposlenikRow(MyUserRow(0), MyZatvorRow(0), MySektorRow(0), .ZaposlenikIme, .ZaposlenikPrezime, .ZaposlenikJMBG, .ZaposlenikDatRod, .ZaposlenikAdresa, _
.ZaposlenikBrTel, .ZaposlenikSS, .ZaposlenikPlaca, .ZaposlenikDatZap, _
.ZaposlenikZatvor, .ZaposlenikSektor, .ZaposlenikVladanje, .ZaposlenikNapomena)
End With
ZaposlenikAdapter.Update(ZaposlenikTable)
Else
Return False
End If
Return True
End Function
I hope this will help somebody:D, cause it sure did cost me my time! :D. And an advice to all newbies like me, just have a little more attention to the details you take for granted or ignore in some point.
|
|
 |