.NETGURU
SQLDataAdapter parameter not supplied during insert?
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-sqlclient' list.


Gary Milczarek
-- Moved from [aspngstart] to [ngfx-sqlclient] by Tony Stark <Click here to reveal e-mail address> --

I'm trying to insert data from a form into SQL Server database. I
dragged
the fields from the database onto the form to create a SQLDataAdapter,
which
creates an automatic insert command.

My submit button calls:
SqlConnection1.Open()
SqlDataAdapter1.InsertCommand.ExecuteNonQuery()
SqlConnection1.Close()

When I submit, I get the error:
Prepared statement '(@UserName varchar(15),@UserPassword
varchar(15),@FirstName varc' expects parameter @UserName, which was not
supplied.

Yet when I look in the SQLDataAdapter auto generated code I see:
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@UserName",
System.Data.SqlDbType.VarChar, 15, txtUserName.Text))

Isn't that the parameter wanted. What is happening here, and what else
do I
need to do?

Thanks,
Gary

Reply to this message...
 
    
Alex Dresko
Perhaps the parameter is there as it should be, but there is not a value
supplied for the parameter?

Alex Dresko
Three Point Oh!

-----Original Message-----
From: Gary Milczarek [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 16, 2002 11:27 AM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] SQLDataAdapter parameter not supplied during
insert?

-- Moved from [aspngstart] to [ngfx-sqlclient] by Tony Stark
<Click here to reveal e-mail address> --

I'm trying to insert data from a form into SQL Server database. I
dragged
the fields from the database onto the form to create a SQLDataAdapter,
which
creates an automatic insert command.

My submit button calls:
SqlConnection1.Open()
SqlDataAdapter1.InsertCommand.ExecuteNonQuery()
SqlConnection1.Close()

When I submit, I get the error:
Prepared statement '(@UserName varchar(15),@UserPassword
varchar(15),@FirstName varc' expects parameter @UserName, which was not
supplied.

Yet when I look in the SQLDataAdapter auto generated code I see:
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@UserName",
System.Data.SqlDbType.VarChar, 15, txtUserName.Text))

Isn't that the parameter wanted. What is happening here, and what else
do I
need to do?

Thanks,
Gary

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT

Reply to this message...
 
    
Gary Milczarek
Indeed, that was the missing part. Here is what worked:
SqlInsertCommand1.Parameters("@UserName").Value = txtUserName.Text

I really couldn't find any documentation or examples of how to use the
DataAdapter in this way and that made it clear what was needed.

Thanks for your response, Alex.

Gary

-----Original Message-----
From: Alex Dresko [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 16, 2002 12:58 PM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] RE: SQLDataAdapter parameter not supplied
during insert?

Perhaps the parameter is there as it should be, but there is not a value
supplied for the parameter?

Alex Dresko
Three Point Oh!

-----Original Message-----
From: Gary Milczarek [mailto:Click here to reveal e-mail address]
Sent: Tuesday, July 16, 2002 11:27 AM
To: ngfx-sqlclient
Subject: [ngfx-sqlclient] SQLDataAdapter parameter not supplied during
insert?

-- Moved from [aspngstart] to [ngfx-sqlclient] by Tony Stark
<Click here to reveal e-mail address> --

I'm trying to insert data from a form into SQL Server database. I
dragged
the fields from the database onto the form to create a SQLDataAdapter,
which
creates an automatic insert command.

My submit button calls:
SqlConnection1.Open()
SqlDataAdapter1.InsertCommand.ExecuteNonQuery()
SqlConnection1.Close()

When I submit, I get the error:
Prepared statement '(@UserName varchar(15),@UserPassword
varchar(15),@FirstName varc' expects parameter @UserName, which was not
supplied.

Yet when I look in the SQLDataAdapter auto generated code I see:
Me.SqlInsertCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@UserName",
System.Data.SqlDbType.VarChar, 15, txtUserName.Text))

Isn't that the parameter wanted. What is happening here, and what else
do I
need to do?

Thanks,
Gary

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT

| [ngfx-sqlclient] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-sqlclient.asp = JOIN/QUIT

Reply to this message...
 
 
System.Data.Common.DataAdapter
System.Data.SqlClient.SqlParameter
System.Data.SqlDbType




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification