[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Object Must Implement IConvertible.   ------ Error.

Posted on 2004-04-08
3
Medium Priority
?
623 Views
Last Modified: 2008-03-06
I am constantly getting this error, how ever i implement or change my code.

the error is "Object must Implement IConvertible"

Dont know how to solve, it. I am getting this error at the last line. SqlCmd.ExecuteNonQuery();


Any Ideas.


Here is the Code, Cut and paste to VS.NET.            


                                  #region public static LogErrorToSqlServer
            static public void LogErrorToSQLServer(
                                          int errorCode,
                                          string errorSource,
                                          string errorCulture,
                                          string errorMessage)
            {
                  SqlConnection SqlConn = null;
                  SqlCommand SqlCmd = null;
                  
                  try
                  {
                        SqlConn = new SqlConnection(Common.DataBaseConnectionString);
                        SqlCmd = new SqlCommand("spInsertError",SqlConn);
                        SqlCmd.CommandType = CommandType.StoredProcedure;
                        
                        SqlParameter paramServer = new SqlParameter("@Server",SqlDbType.VarChar,8);
                        paramServer.Value = System.Web.HttpContext.Current.Server.MachineName;
                        paramServer.Direction = ParameterDirection.Input;
                        SqlCmd.Parameters.Add(paramServer);
                  
                        SqlParameter paramPageURL = new SqlParameter("@PageURL",SqlDbType.VarChar,127);
                        paramPageURL.Value = System.Web.HttpContext.Current.Request.Url;
                        paramPageURL.Direction = ParameterDirection.Input;
                        SqlCmd.Parameters.Add(paramPageURL);

                        SqlParameter paramQueryString = new SqlParameter("@QueryString",SqlDbType.VarChar,127);
                        paramQueryString.Value = System.Web.HttpContext.Current.Request.QueryString;
                        paramQueryString.Direction  = ParameterDirection.Input;
                        SqlCmd.Parameters.Add(paramQueryString);

                        SqlParameter paramSource = new SqlParameter("@ErrorSource",SqlDbType.VarChar,32);
                        paramSource.Value = errorSource;
                        paramSource.Direction  = ParameterDirection.Input;
                        SqlCmd.Parameters.Add(paramSource);

                        SqlParameter paramCode = new SqlParameter("@ErrorCode",SqlDbType.Int,4);
                        paramCode.Value = errorCode;
                        paramCode.Direction = ParameterDirection.Input;
                        SqlCmd.Parameters.Add(paramCode);

                        SqlParameter paramCulture = new SqlParameter("@ErrorCulture",SqlDbType.VarChar,8);
                        paramCulture.Value = errorCulture;
                        paramCulture.Direction = ParameterDirection.Input;
                        SqlCmd.Parameters.Add(paramCulture);

                        SqlParameter paramMessage = new  SqlParameter("@ErrorMessage",SqlDbType.VarChar,512);
                        paramMessage.Value = errorMessage;
                        paramMessage.Direction = ParameterDirection.Input;
                        SqlCmd.Parameters.Add(paramMessage);

                        SqlConn.Open();
                        SqlCmd.ExecuteNonQuery();
                  }
                  catch (Exception ex)
                  {
                        ex.ToString();
                  }
                  finally
                  {
                        
                        if (SqlCmd != null) SqlCmd.Dispose();
                        if (SqlConn != null) { if (SqlConn.State != System.Data.ConnectionState.Closed) SqlConn.Close(); SqlConn.Dispose(); }
                  }
            }
            #endregion
0
Comment
Question by:steve_mick972
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Assisted Solution

by:dfiala13
dfiala13 earned 400 total points
ID: 10789090
In this case one of your parameters is not the type you expect.  Double check the signature on your stored proc. Could also be some funky characters in your query string param.  Brute force case, strip down to one param and add them in until one breaks.
0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 1600 total points
ID: 10791240


it's also possible that you might be trying to send a C# null value to the stored procedure when the stored procedure might allow a DbNull which is different than a C# null.

But now that I've spit that out, I think it actually throws a different error than what you've provided.


follw dfiala's suggestion and if some reason that doesn't pan out, then look for a data error
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 10791248


Also... if you post the header to the stored procedure someone here may be able to point out your error (if you can't find it).
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question