Home All Groups Group Topic Archive Search About
Author
23 Jun 2006 9:45 AM
Oxns
Hi,

Hope this is the right forum.

Calling a SQL Express database (which is working fine), from a Web Page
using C#.

Get the Exception :

No mapping exists from object type System.Data.SqlClient.SqlCommand to a
known managed provider native type

Code all looks good to me, the connection seems OK. In fact the
SqlConnection Open() works fine.

Error thrown at cmd.ExecuteNonQuery.

Cmd type is SP, which exists, passing in 7 parameters - which look good.

Any ideas please ???.

Many thanks

regards

Graham


string strconn =
System.Configuration.ConfigurationManager.AppSettings["SiteSqlServer"];

SqlConnection conn = new SqlConnection(strconn);

string sql = "SS_WriteReaderPost";

SqlCommand cmd = new SqlCommand(sql, conn);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("@ReaderId", keyid);

cmd.Parameters.Add("@Cmd", cmd);

cmd.Parameters.Add("@KeyId", keyid);

cmd.Parameters.Add("@NumBlocks", numblocks);

cmd.Parameters.Add("@Block", block);

cmd.Parameters.Add("@Time", dt);

cmd.Parameters.Add("@DataField", datafield);

cmd.Connection.Open();

resp = cmd.ExecuteNonQuery();



cmd.Connection.Close();

Author
23 Jun 2006 10:22 AM
Oxns
Sorry guys,

The problem was caused (but misleadingly reported) because I had a class
variable called cmd (string), then created a Method variable cmd
(SqlCommand), and tried to pass this one in as a parameter value.

Smply renaming the SqlCommand to sqlcmd worked ;-)).

Graham

Show quote
"Oxns" <oxns@community.nospam> wrote in message
news:%23iLyAnqlGHA.4244@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> Hope this is the right forum.
>
> Calling a SQL Express database (which is working fine), from a Web Page
> using C#.
>
> Get the Exception :
>
> No mapping exists from object type System.Data.SqlClient.SqlCommand to a
> known managed provider native type
>
> Code all looks good to me, the connection seems OK. In fact the
> SqlConnection Open() works fine.
>
> Error thrown at cmd.ExecuteNonQuery.
>
> Cmd type is SP, which exists, passing in 7 parameters - which look good.
>
> Any ideas please ???.
>
> Many thanks
>
> regards
>
> Graham
>
>
> string strconn =
> System.Configuration.ConfigurationManager.AppSettings["SiteSqlServer"];
>
> SqlConnection conn = new SqlConnection(strconn);
>
> string sql = "SS_WriteReaderPost";
>
> SqlCommand cmd = new SqlCommand(sql, conn);
>
> cmd.CommandType = CommandType.StoredProcedure;
>
> cmd.Parameters.Add("@ReaderId", keyid);
>
> cmd.Parameters.Add("@Cmd", cmd);
>
> cmd.Parameters.Add("@KeyId", keyid);
>
> cmd.Parameters.Add("@NumBlocks", numblocks);
>
> cmd.Parameters.Add("@Block", block);
>
> cmd.Parameters.Add("@Time", dt);
>
> cmd.Parameters.Add("@DataField", datafield);
>
> cmd.Connection.Open();
>
> resp = cmd.ExecuteNonQuery();
>
>
>
> cmd.Connection.Close();
>
>

AddThis Social Bookmark Button