Insert i ASP.NET
Jeg prøver helt stille og roligt at indsætte data i min database (som ligger på en mysql server) via min asp.net side.Dette virker på min egen computer(localhost) men ikke på serveren. Jeg har prøvet at ændre på syntaksen 100 gange, og jeg har testet på serveren hvor man kan lave direkte input.
OdbcConnection dbConn;
dbConn = new OdbcConnection (sConnection);
dbConn.Open();
//definere sql sætning
string sql = "INSERT INTO qwe VALUES(12);";
//opretter en dbCommand der tager sig af sql kommandoen.
OdbcCommand dbCmd;
dbCmd = new OdbcCommand();
dbCmd.CommandText = sql;
dbCmd.Connection = dbConn;
//laver et obj der skal håndtere de data der kommer tilbage.
dbCmd.ExecuteNonQuery();
dbConn.Close();
Hvad er der galt ?????
Jeg får følgende fejl:
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[FormatException: Input string was not in a correct format.]
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +0
System.Int32.Parse(String s) +38
login1.WebForm4.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\login1\webform4.aspx.cs:61
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
