Setting Parameters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When setting parameters, I get the error:

System.IndexOutOfRangeException: Invalid index -1

With Me.MySqlCommand1
.Parameters("@FileName").Value = sFileName
.ExecuteNonQuery()
End With


The insert statement is:

INSERT INTO management (FileName) VALUES (@FileName)

Any ideas what's gone wrong?
 
Hi,

You must create the parameter before setting its value, declaring the
parameter in the SQL query doesn't make it available in the Parameters
collection.

In C# this is somthing like this (I'm not familiar with VB.net) :

SqlParameter param=new SqlParameter("@FileName",SqlDbType.String);
Param.Value = sFileName;
MySqlCommand1.Parameters.Add(param);
MySqlCommand1.ExecuteNonQuery();

Hope this will help you.

Kant


Le 7/08/05 13:07, dans (e-mail address removed),
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top