|
-
Dec 23rd, 2003, 04:58 PM
#1
Thread Starter
Frenzied Member
dataadapter missing parameters error [Resolved]
I'm starting a new Solution that has almost the same forms and code as the previous one I worked on (which does work fine, thanks for the help).
Outside of a few minor code, SQL and path changes, these Solutions are nearly identical. So, I copied the files in the first solution to a new folder, renamed and saved everything under a new name, and made some path and name changes.
Now, though, when the project starts up, I get an error when I fill the dataadapter (da.fill(ds, "WhiteSlips") that says Table Not Found. I absolutely guarantee the table is there. It's on my desktop, I can open it, I pasted the path in case I typo'd it, etc.
The only thing I can think of is that in the AssemblyInfo.vb file, they have the same GUID, since it's a copy of the first.
Any ideas short of redoing the whole solution and code? Thanks.
Last edited by salvelinus; Dec 24th, 2003 at 11:13 AM.
-
Dec 24th, 2003, 08:43 AM
#2
Thread Starter
Frenzied Member
Looking into the ex.message in the exception thrown at da.fill(ds, "WhiteSlips"), it says "No value given for one or more parameters"
The relevant code is below. What's more, except for changing White from Purple, rhis same code works in the other Solution. The Catch included is the one that is called.
VB Code:
Dim mstrPath As String = "C:\Documents and Settings\greg\Desktop\Test White\WhiteSlips.mdb"
Dim mstrCn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & mstrPath
'Variables used in Sub New() to retrieve records for Review mode.
Dim cn As OleDbConnection
Dim cmd As New OleDbCommand()
Dim da As New OleDbDataAdapter()
Dim ds As New DataSet()
'etc
strSQL = "SELECT [Database], [ChooseProject], [Subject], [SurveyNumber], [Month], [PatientNumber], [Area/Page], [PatientName], [ComputerNumber], [PatientPhone], [InterviewerNumber], [Discharge/ServiceDate], [Message], [ID] "
strSQL += "FROM WhiteSlips "
strSQL += "WHERE WhiteSlips.From = " & "'" & mstrUserName & "'"
cn = New OleDbConnection(mstrCn)
cmd = cn.CreateCommand
cmd.CommandText = strSQL
da.SelectCommand = cmd
Try
da.Fill(ds, "WhiteSlips")
Catch ex As SystemException
MsgBox("Table WhiteSlips not found." & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "Error in Sub New()")
Me.Close()
-
Dec 24th, 2003, 09:47 AM
#3
Sleep mode
How many columns in your db !! . Better you use "SELECT *...etc) . And you don't really need command obj . Try this .
VB Code:
Dim mstrPath As String = "C:\Documents and Settings\greg\Desktop\Test White\WhiteSlips.mdb"
Dim mstrCn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & mstrPath
'Variables used in Sub New() to retrieve records for Review mode.
Dim cn As New OleDbConnection(mstrCn)
Dim ds As New DataSet
'etc
strSQL = "SELECT [Database], [ChooseProject], [Subject], [SurveyNumber], [Month], [PatientNumber], [Area/Page], [PatientName], [ComputerNumber], [PatientPhone], [InterviewerNumber], [Discharge/ServiceDate], [Message], [ID] "
strSQL += "FROM WhiteSlips "
strSQL += "WHERE WhiteSlips.From = " & "'" & mstrUserName & "'"
Dim da As New OleDbDataAdapter(strSQL, cn)
Try
da.Fill(ds, "WhiteSlips")
Catch ex As Exception
MsgBox("Table WhiteSlips not found." & vbCrLf & ex.Message, MsgBoxStyle.Exclamation, "Error in Sub New()")
Me.Close()
End Try
-
Dec 24th, 2003, 10:45 AM
#4
Thread Starter
Frenzied Member
Thanks Pirate.
Selecting * worked, but I couldn't figure out why. Then I remembered that I'd had to add the ID field to the first db in order to have a primary key. Once I added it to this db, it worked like it was supposed to.
There are 4 or 5 other fields that I don't select. Assuming I do select individual fields, not *, do I still need the cmd object? (I may use it elsewhere, would have to check).
Also, since both the first app & this one have the same AssemblyInfo guid, will that cause a problem if they're both deployed on the same machine? How to change it if so?
I also work with an old DOS based db, FilePro, where each table is considered a database. Each client has their own database in this setup. This means that the database/table has up to 400 fields. Luckily, my boss is the main one working with that.
-
Dec 24th, 2003, 11:01 AM
#5
Sleep mode
OleCommand objs are mainly when inserting data or when you use OleDataReader objs to execute SQL Statements and retrieve data (Update , Delete , Insert ) . So , in your situation , you don't really need it since you are filling a dataset obj and work in disconnect mode .
For the conflicts in your projs , I'd advice to create another proj beside the current you are working with , just to avoid confusion and problems later on since I'm not sure what problems may happen after deployment .
-
Dec 24th, 2003, 11:12 AM
#6
Thread Starter
Frenzied Member
Ok, thanks Pirate. Good advice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|