Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: objCommand.ExecuteNonQuery() : Error


Message #1 by rustin@e... on Wed, 29 May 2002 15:03:02 +0200
This is a multi-part message in MIME format.

------=_NextPart_000_009F_01C20721.EE764A00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

 Hi guys,

Im trying to update data in Acces database but i keep on getting this error,
not sure why, can you please help.

The source code is listed below.

Thanks
 Rustin



Server Error in '/' Application.
----------------------------------------------------------------------------
----

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:


Line 97:
Line 98:
Line 99: objCommand.ExecuteNonQuery()
Line 100:objConnection.Close()
Line 101:



Source File: \\genfs1\www16\redhead1\update.aspx    Line: 99

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo
info) +0
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) +40
   System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider) +569
   System.Data.OleDb.OleDbParameter.GetParameterValue() +173
   System.Data.OleDb.OleDbParameter.GetParameterScale() +28
   System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings
bindings, tagDBPARAMBINDINFO[] bindInfo) +129
   System.Data.OleDb.OleDbCommand.CreateAccessor() +151
   System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior
behavior, Boolean throwifnotsupported) +175
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) +22
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +54
   ASP.update_aspx.Updatedata(Object sender, EventArgs e) in
\\genfs1\www16\redhead1\update.aspx:99
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(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() +1263






<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<html>
 <head>
<title>ASP.NET Employee Directory Management Screen</title>

<script language="VB" runat="server">

  sub Page_Load(sender as Object, e as EventArgs)



'Create connection string
    Dim connString as String
    connString = ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("\redhead1\db\EMPLOY.mdb"))

'Open a connection
    Dim objConnection as OleDbConnection
    objConnection = New OleDbConnection(connString)
    objConnection.Open()


Dim strSQL as String
strSQL = "SELECT * FROM CIEmpDir WHERE EmployeeID = @id"
 'Create Command object
    Dim objCommand as OleDbCommand
    objCommand = New OleDbCommand(strSQL, objConnection)


objCommand.Parameters.Add( New OleDbParameter( "@id", OleDbType.Integer,
75 ))
objCommand.Parameters( "@id" ).Value = request.querystring("id")

    'Get a Datareader
    Dim objDataReader as OleDbDataReader
    objDataReader 
objCommand.ExecuteReader(CommandBehavior.CloseConnection)

    'Do the DataBinding
    Results.DataSource = objDataReader
    Results.DataBind()

    'Close the datareader/db connection
    objDataReader.Close()
  end sub

sub Updatedata(sender as Object, e as EventArgs)




'Create connection string
    Dim connString as String
    connString = ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("\redhead1\db\EMPLOY.mdb"))

'Open a connection
    Dim objConnection as OleDbConnection
    objConnection = New OleDbConnection(connString)
    objConnection.Open()


Dim strSQL as String



strSQL = "update CiEmpDir set name='@n...', emailaddress='@e...',
PhoneNumber='@p...', department='department' where employeeID='@i...'"

'Create Command object
    Dim objCommand as OleDbCommand
    objCommand = New OleDbCommand(strSQL, objConnection)



objCommand.Parameters.Add( New OleDbParameter( "@email", OleDbType.Varchar,
35 ))
objCommand.Parameters( "@email" ).Value = "edtemail.text"

objCommand.Parameters.Add( New OleDbParameter( "@Name", OleDbType.Varchar,
35 ))
objCommand.Parameters( "@Name" ).Value = "edtname.text"



objCommand.Parameters.Add( New OleDbParameter( "@phone", OleDbType.Integer,
10 ))
objCommand.Parameters( "@phone" ).Value = "edtphone.text"


objCommand.Parameters.Add( New OleDbParameter( "@department",
OleDbType.Varchar, 35 ))
objCommand.Parameters( "@department" ).Value = "edtdepartment.Text"


objCommand.Parameters.Add( New OleDbParameter( "@id", OleDbType.Integer,
35 ))
objCommand.Parameters( "@id" ).Value = request.querystring("id")


objCommand.ExecuteNonQuery()
objConnection.Close()

end sub




</script>
</head>
<body>

<ASP:DataGrid
      id="Results"
      runat="server"
      Width="650"
      BackColor="#ffbd4a"
      BorderColor="black"
      ShowFooter="false"
      CellPadding=3
      CellSpacing="0"
      Font-Name="Verdana"
      Font-Size="8pt"
      AutoGenerateColumns="false"
      EnableViewState="False"
      ShowHeader="true"
      HeaderStyle-BackColor="#e7944a"
      AlternatingItemStyle-BackColor="#eeffee"
      SelectedItemStyle-BackColor="yellow">



<columns>



  <asp:TemplateColumn runat="server" HeaderText="Employee Name">
<itemTemplate>

   <form runat="server">
      <table style="background-color: #0eff24;>;
         font: 10pt verdana;border-width:1;border-style:solid;
         border-color:black;" cellspacing=15>
         <tr>
            <td><b>Employee Name</b></td>
            <td>
<ASP:TextBox id="edtname" runat="server" value='<%#
ontainer.DataItem( "name" )%>'/></td>
         </tr>
         <tr>
            <td><b>Email</b></td>
            <td>
<ASP:TextBox id="edtemail"   runat="server" value='<%#
ontainer.DataItem( "emailAddress" )%>'/></td>
         </tr>

     <tr>
            <td><b>Department</b></td>
            <td>
<ASP:TextBox id="edtdepartment" runat="server" value='<%#
Container.DataItem( "Department" )%>'/></td>
         </tr>

     <tr>
            <td><b>Phone</b></td>
            <td>
<ASP:TextBox id="edtphone" runat="server" value='<%#
ontainer.DataItem( "PhoneNumber" )%>'/></td>
         </tr>



         <tr>
            <td></td>
            <td><ASP:Button Text="Submit" runat="server"
                   OnClick="Updatedata" /></td>
         </tr>
      </table>

   </form>

 </itemTemplate>
</asp:TemplateColumn>
</columns>
</ASP:DataGrid>
</body>
</html>





Message #2 by "Manuj Sarpal" <manujsarpal@h...> on Wed, 29 May 2002 14:32:32 +0100
This is a multi-part message in MIME format.

------=_NextPart_000_016C_01C2071D.AAD4E440
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Rustin,

you are using wrong sql string.
strSQL =3D "update CiEmpDir set name=3D'@n...', emailaddress=3D'@e...', 
PhoneNumber=3D'@p...', department=3D'department' where 
employeeID=3D'@i...'"
         it should be

strSQL =3D "update CiEmpDir set name=3D'@n...', emailaddress=3D'@e...', 
PhoneNumber=3D'@p...', department=3D'@d...' where 
employeeID=3D'@i...'"

try to check the sql string its not proper  it should be             
department =3D'@d...'

Hope it helps..

Manuj




  ----- Original Message -----
  From: Rustin Daniels
  To: ASP+
  Sent: Wednesday, May 29, 2002 2:03 PM
  Subject: [aspx] objCommand.ExecuteNonQuery() : Error


   Hi guys,

  Im trying to update data in Acces database but i keep on getting this 
error, not sure why, can you please help.

  The source code is listed below.

  Thanks
   Rustin



  Server Error in '/' Application.
-------------------------------------------------------------------------
-----

  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:


Line 97:
Line 98:
Line 99: objCommand.ExecuteNonQuery()
Line 100:objConnection.Close()
Line 101:
      


  Source File: \\genfs1\www16\redhead1\update.aspx    Line: 99

  Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.ParseInt32(String s, NumberStyles style, 
NumberFormatInfo info) +0
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) 
+40
   System.Convert.ChangeType(Object value, Type conversionType, 
IFormatProvider provider) +569
   System.Data.OleDb.OleDbParameter.GetParameterValue() +173
   System.Data.OleDb.OleDbParameter.GetParameterScale() +28
   System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings 
bindings, tagDBPARAMBINDINFO[] bindInfo) +129
   System.Data.OleDb.OleDbCommand.CreateAccessor() +151
   System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior 
behavior, Boolean throwifnotsupported) +175
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior 
behavior, Object& executeResult) +22
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior 
behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +54
   ASP.update_aspx.Updatedata(Object sender, EventArgs e) in 
\\genfs1\www16\redhead1\update.aspx:99
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Rais
ePostBackEvent(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() +1263

      




  <%@ Import Namespace=3D"System.Data" %>
  <%@ Import Namespace=3D"System.Data.OleDb" %>
  
  <html>
   <head>
  <title>ASP.NET Employee Directory Management Screen</title>
  
  <script language=3D"VB" runat=3D"server">
  
    sub Page_Load(sender as Object, e as EventArgs)



  'Create connection string
      Dim connString as String
      connString =3D ("Provider=3DMicrosoft.Jet.OLEDB.4.0; Data 
Source=3D" & Server.MapPath("\redhead1\db\EMPLOY.mdb"))
  
  'Open a connection
      Dim objConnection as OleDbConnection
      objConnection =3D New OleDbConnection(connString)
      objConnection.Open()
   
  
  Dim strSQL as String
  strSQL =3D "SELECT * FROM CIEmpDir WHERE EmployeeID =3D @id"
   'Create Command object
      Dim objCommand as OleDbCommand
      objCommand =3D New OleDbCommand(strSQL, objConnection)
  

  objCommand.Parameters.Add( New OleDbParameter( "@id", 
OleDbType.Integer, 75 ))
  objCommand.Parameters( "@id" ).Value =3D request.querystring("id")

      'Get a Datareader
      Dim objDataReader as OleDbDataReader
      objDataReader =3D 
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
  
      'Do the DataBinding
      Results.DataSource =3D objDataReader
      Results.DataBind()   
     
      'Close the datareader/db connection
      objDataReader.Close()
    end sub
  
  sub Updatedata(sender as Object, e as EventArgs)


  
  
  'Create connection string
      Dim connString as String
      connString =3D ("Provider=3DMicrosoft.Jet.OLEDB.4.0; Data 
Source=3D" & Server.MapPath("\redhead1\db\EMPLOY.mdb"))
  
  'Open a connection
      Dim objConnection as OleDbConnection
      objConnection =3D New OleDbConnection(connString)
      objConnection.Open()
   
  
  Dim strSQL as String



  strSQL =3D "update CiEmpDir set name=3D'@n...', 
emailaddress=3D'@e...', PhoneNumber=3D'@p...', 
department=3D'department' where employeeID=3D'@i...'"
  
  'Create Command object
      Dim objCommand as OleDbCommand
      objCommand =3D New OleDbCommand(strSQL, objConnection)

   

  objCommand.Parameters.Add( New OleDbParameter( "@email", 
OleDbType.Varchar, 35 ))
  objCommand.Parameters( "@email" ).Value =3D "edtemail.text"

  objCommand.Parameters.Add( New OleDbParameter( "@Name", 
OleDbType.Varchar, 35 ))
  objCommand.Parameters( "@Name" ).Value =3D "edtname.text"
  


  objCommand.Parameters.Add( New OleDbParameter( "@phone", 
OleDbType.Integer, 10 ))
  objCommand.Parameters( "@phone" ).Value =3D "edtphone.text"


  objCommand.Parameters.Add( New OleDbParameter( "@department", 
OleDbType.Varchar, 35 ))
  objCommand.Parameters( "@department" ).Value =3D "edtdepartment.Text"


  objCommand.Parameters.Add( New OleDbParameter( "@id", 
OleDbType.Integer, 35 ))
  objCommand.Parameters( "@id" ).Value =3D request.querystring("id")


  objCommand.ExecuteNonQuery()
  objConnection.Close()

  end sub




  </script>
  </head>
  <body>

  <ASP:DataGrid
        id=3D"Results"
        runat=3D"server"
        Width=3D"650"
        BackColor=3D"#ffbd4a"
        BorderColor=3D"black"
        ShowFooter=3D"false"
        CellPadding=3D3
        CellSpacing=3D"0"
        Font-Name=3D"Verdana"
        Font-Size=3D"8pt"
        AutoGenerateColumns=3D"false"
        EnableViewState=3D"False"
        ShowHeader=3D"true"
        HeaderStyle-BackColor=3D"#e7944a"
        AlternatingItemStyle-BackColor=3D"#eeffee"
        SelectedItemStyle-BackColor=3D"yellow">
               
               

  <columns>
     

     
    <asp:TemplateColumn runat=3D"server" HeaderText=3D"Employee Name"> 
  <itemTemplate>

     <form runat=3D"server">
        <table style=3D"background-color: #0eff24;>;
           font: 10pt verdana;border-width:1;border-style:solid;
           border-color:black;" cellspacing=3D15>
           <tr>
              <td><b>Employee Name</b></td>
              <td>
  <ASP:TextBox id=3D"edtname" runat=3D"server" value=3D'<%# 
Container.DataItem( "name" )%>'/></td>
           </tr>
           <tr>
              <td><b>Email</b></td>
              <td>
  <ASP:TextBox id=3D"edtemail"   runat=3D"server" value=3D'<%# 
Container.DataItem( "emailAddress" )%>'/></td>
           </tr>
      
       <tr>
              <td><b>Department</b></td>
              <td>
  <ASP:TextBox id=3D"edtdepartment" runat=3D"server" value=3D'<%# 
Container.DataItem( "Department" )%>'/></td>
           </tr>
      
       <tr>
              <td><b>Phone</b></td>
              <td>
  <ASP:TextBox id=3D"edtphone" runat=3D"server" value=3D'<%# 
Container.DataItem( "PhoneNumber" )%>'/></td>
           </tr>
      
      
      
           <tr>
              <td></td>
              <td><ASP:Button Text=3D"Submit" runat=3D"server"
                     OnClick=3D"Updatedata" /></td>
           </tr>
        </table>
     
     </form>

   </itemTemplate>
  </asp:TemplateColumn>
  </columns>
  </ASP:DataGrid>
  </body>
  </html>



  --- Change your mail options at http://p2p.wrox.com/manager.asp or to 
unsubscribe send a blank email to 

Message #3 by "Manuj Sarpal" <manujsarpal@h...> on Wed, 29 May 2002 14:37:58 +0100
This is a multi-part message in MIME format.

------=_NextPart_000_0180_01C2071E.6D832600
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Rustin ,

There is one more error in your update function ie

objCommand.Parameters( "@email" ).Value =3D "edtemail.text"

should be

objCommand.Parameters( "@email" ).Value =3D edtemail.text

(you have to put all the values and not the strings edtemail.text  in 
the table.. so remove all the "" in the code)
I hope it will work now..

Regards
Manuj





  ----- Original Message -----
  From: Rustin Daniels
  To: ASP+
  Sent: Wednesday, May 29, 2002 2:03 PM
  Subject: [aspx] objCommand.ExecuteNonQuery() : Error


   Hi guys,

  Im trying to update data in Acces database but i keep on getting this 
error, not sure why, can you please help.

  The source code is listed below.

  Thanks
   Rustin



  Server Error in '/' Application.
-------------------------------------------------------------------------
-----

  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:


Line 97:
Line 98:
Line 99: objCommand.ExecuteNonQuery()
Line 100:objConnection.Close()
Line 101:
      


  Source File: \\genfs1\www16\redhead1\update.aspx    Line: 99

  Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.ParseInt32(String s, NumberStyles style, 
NumberFormatInfo info) +0
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) 
+40
   System.Convert.ChangeType(Object value, Type conversionType, 
IFormatProvider provider) +569
   System.Data.OleDb.OleDbParameter.GetParameterValue() +173
   System.Data.OleDb.OleDbParameter.GetParameterScale() +28
   System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings 
bindings, tagDBPARAMBINDINFO[] bindInfo) +129
   System.Data.OleDb.OleDbCommand.CreateAccessor() +151
   System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior 
behavior, Boolean throwifnotsupported) +175
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior 
behavior, Object& executeResult) +22
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior 
behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +54
   ASP.update_aspx.Updatedata(Object sender, EventArgs e) in 
\\genfs1\www16\redhead1\update.aspx:99
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Rais
ePostBackEvent(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() +1263

      




  <%@ Import Namespace=3D"System.Data" %>
  <%@ Import Namespace=3D"System.Data.OleDb" %>
  
  <html>
   <head>
  <title>ASP.NET Employee Directory Management Screen</title>
  
  <script language=3D"VB" runat=3D"server">
  
    sub Page_Load(sender as Object, e as EventArgs)



  'Create connection string
      Dim connString as String
      connString =3D ("Provider=3DMicrosoft.Jet.OLEDB.4.0; Data 
Source=3D" & Server.MapPath("\redhead1\db\EMPLOY.mdb"))
  
  'Open a connection
      Dim objConnection as OleDbConnection
      objConnection =3D New OleDbConnection(connString)
      objConnection.Open()
   
  
  Dim strSQL as String
  strSQL =3D "SELECT * FROM CIEmpDir WHERE EmployeeID =3D @id"
   'Create Command object
      Dim objCommand as OleDbCommand
      objCommand =3D New OleDbCommand(strSQL, objConnection)
  

  objCommand.Parameters.Add( New OleDbParameter( "@id", 
OleDbType.Integer, 75 ))
  objCommand.Parameters( "@id" ).Value =3D request.querystring("id")

      'Get a Datareader
      Dim objDataReader as OleDbDataReader
      objDataReader =3D 
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
  
      'Do the DataBinding
      Results.DataSource =3D objDataReader
      Results.DataBind()   
     
      'Close the datareader/db connection
      objDataReader.Close()
    end sub
  
  sub Updatedata(sender as Object, e as EventArgs)


  
  
  'Create connection string
      Dim connString as String
      connString =3D ("Provider=3DMicrosoft.Jet.OLEDB.4.0; Data 
Source=3D" & Server.MapPath("\redhead1\db\EMPLOY.mdb"))
  
  'Open a connection
      Dim objConnection as OleDbConnection
      objConnection =3D New OleDbConnection(connString)
      objConnection.Open()
   
  
  Dim strSQL as String



  strSQL =3D "update CiEmpDir set name=3D'@n...', 
emailaddress=3D'@e...', PhoneNumber=3D'@p...', 
department=3D'department' where employeeID=3D'@i...'"
  
  'Create Command object
      Dim objCommand as OleDbCommand
      objCommand =3D New OleDbCommand(strSQL, objConnection)

   

  objCommand.Parameters.Add( New OleDbParameter( "@email", 
OleDbType.Varchar, 35 ))
  objCommand.Parameters( "@email" ).Value =3D "edtemail.text"

  objCommand.Parameters.Add( New OleDbParameter( "@Name", 
OleDbType.Varchar, 35 ))
  objCommand.Parameters( "@Name" ).Value =3D "edtname.text"
  


  objCommand.Parameters.Add( New OleDbParameter( "@phone", 
OleDbType.Integer, 10 ))
  objCommand.Parameters( "@phone" ).Value =3D "edtphone.text"


  objCommand.Parameters.Add( New OleDbParameter( "@department", 
OleDbType.Varchar, 35 ))
  objCommand.Parameters( "@department" ).Value =3D "edtdepartment.Text"


  objCommand.Parameters.Add( New OleDbParameter( "@id", 
OleDbType.Integer, 35 ))
  objCommand.Parameters( "@id" ).Value =3D request.querystring("id")


  objCommand.ExecuteNonQuery()
  objConnection.Close()

  end sub




  </script>
  </head>
  <body>

  <ASP:DataGrid
        id=3D"Results"
        runat=3D"server"
        Width=3D"650"
        BackColor=3D"#ffbd4a"
        BorderColor=3D"black"
        ShowFooter=3D"false"
        CellPadding=3D3
        CellSpacing=3D"0"
        Font-Name=3D"Verdana"
        Font-Size=3D"8pt"
        AutoGenerateColumns=3D"false"
        EnableViewState=3D"False"
        ShowHeader=3D"true"
        HeaderStyle-BackColor=3D"#e7944a"
        AlternatingItemStyle-BackColor=3D"#eeffee"
        SelectedItemStyle-BackColor=3D"yellow">
               
               

  <columns>
     

     
    <asp:TemplateColumn runat=3D"server" HeaderText=3D"Employee Name"> 
  <itemTemplate>

     <form runat=3D"server">
        <table style=3D"background-color: #0eff24;>;
           font: 10pt verdana;border-width:1;border-style:solid;
           border-color:black;" cellspacing=3D15>
           <tr>
              <td><b>Employee Name</b></td>
              <td>
  <ASP:TextBox id=3D"edtname" runat=3D"server" value=3D'<%# 
Container.DataItem( "name" )%>'/></td>
           </tr>
           <tr>
              <td><b>Email</b></td>
              <td>
  <ASP:TextBox id=3D"edtemail"   runat=3D"server" value=3D'<%# 
Container.DataItem( "emailAddress" )%>'/></td>
           </tr>
      
       <tr>
              <td><b>Department</b></td>
              <td>
  <ASP:TextBox id=3D"edtdepartment" runat=3D"server" value=3D'<%# 
Container.DataItem( "Department" )%>'/></td>
           </tr>
      
       <tr>
              <td><b>Phone</b></td>
              <td>
  <ASP:TextBox id=3D"edtphone" runat=3D"server" value=3D'<%# 
Container.DataItem( "PhoneNumber" )%>'/></td>
           </tr>
      
      
      
           <tr>
              <td></td>
              <td><ASP:Button Text=3D"Submit" runat=3D"server"
                     OnClick=3D"Updatedata" /></td>
           </tr>
        </table>
     
     </form>

   </itemTemplate>
  </asp:TemplateColumn>
  </columns>
  </ASP:DataGrid>
  </body>
  </html>



  --- Change your mail options at http://p2p.wrox.com/manager.asp or to 
unsubscribe send a blank email to 

Message #4 by rustin@e... on Wed, 29 May 2002 16:00:42 +0200
This is a multi-part message in MIME format.

------=_NextPart_000_00B2_01C20729.FCDB76D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi Manuji,

I did what you advised and I get the following error.
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'edtemail' is not declared.

Source Error:


Line 72:
Line 73: objCommand.Parameters.Add( New OleDbParameter( "@email",
OleDbType.Varchar, 35 ))
Line 74: objCommand.Parameters( "@email" ).Value = edtemail.text
Line 75:
Line 76: objCommand.Parameters.Add( New OleDbParameter( "@Name",
OleDbType.Varchar, 35 ))


Source File: \\genfs1\www16\redhead1\update.aspx    Line: 74
  -----Original Message-----
  From: Manuj Sarpal [mailto:manujsarpal@h...]
  Sent: 29 May 2002 03:38
  To: ASP+
  Subject: [aspx] Re: objCommand.ExecuteNonQuery() : Error


  Rustin ,

  There is one more error in your update function ie

  objCommand.Parameters( "@email" ).Value = "edtemail.text"

  should be

  objCommand.Parameters( "@email" ).Value = edtemail.text

  (you have to put all the values and not the strings edtemail.text  in the
table.. so remove all the "" in the code)
  I hope it will work now..

  Regards
  Manuj





    ----- Original Message -----
    From: Rustin Daniels
    To: ASP+
    Sent: Wednesday, May 29, 2002 2:03 PM
    Subject: [aspx] objCommand.ExecuteNonQuery() : Error


     Hi guys,

    Im trying to update data in Acces database but i keep on getting this
error, not sure why, can you please help.

    The source code is listed below.

    Thanks
     Rustin



    Server Error in '/' Application.
----------------------------------------------------------------------------

    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:


Line 97:
Line 98:
Line 99: objCommand.ExecuteNonQuery()
Line 100:objConnection.Close()
Line 101:



    Source File: \\genfs1\www16\redhead1\update.aspx    Line: 99

    Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo
info) +0
   System.String.System.IConvertible.ToInt32(IFormatProvider provider) +40
   System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider) +569
   System.Data.OleDb.OleDbParameter.GetParameterValue() +173
   System.Data.OleDb.OleDbParameter.GetParameterScale() +28
   System.Data.OleDb.OleDbParameter.BindParameter(Int32 i, DBBindings
bindings, tagDBPARAMBINDINFO[] bindInfo) +129
   System.Data.OleDb.OleDbCommand.CreateAccessor() +151
   System.Data.OleDb.OleDbCommand.InitializeCommand(CommandBehavior
behavior, Boolean throwifnotsupported) +175
   System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) +22
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +54
   ASP.update_aspx.Updatedata(Object sender, EventArgs e) in
\\genfs1\www16\redhead1\update.aspx:99
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(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() +1263






    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.OleDb" %>

    <html>
     <head>
    <title>ASP.NET Employee Directory Management Screen</title>

    <script language="VB" runat="server">

      sub Page_Load(sender as Object, e as EventArgs)



    'Create connection string
        Dim connString as String
        connString = ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("\redhead1\db\EMPLOY.mdb"))

    'Open a connection
        Dim objConnection as OleDbConnection
        objConnection = New OleDbConnection(connString)
        objConnection.Open()


    Dim strSQL as String
    strSQL = "SELECT * FROM CIEmpDir WHERE EmployeeID = @id"
     'Create Command object
        Dim objCommand as OleDbCommand
        objCommand = New OleDbCommand(strSQL, objConnection)


    objCommand.Parameters.Add( New OleDbParameter( "@id", OleDbType.Integer,
75 ))
    objCommand.Parameters( "@id" ).Value = request.querystring("id")

        'Get a Datareader
        Dim objDataReader as OleDbDataReader
        objDataReader 
objCommand.ExecuteReader(CommandBehavior.CloseConnection)

        'Do the DataBinding
        Results.DataSource = objDataReader
        Results.DataBind()

        'Close the datareader/db connection
        objDataReader.Close()
      end sub

    sub Updatedata(sender as Object, e as EventArgs)




    'Create connection string
        Dim connString as String
        connString = ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("\redhead1\db\EMPLOY.mdb"))

    'Open a connection
        Dim objConnection as OleDbConnection
        objConnection = New OleDbConnection(connString)
        objConnection.Open()


    Dim strSQL as String



    strSQL = "update CiEmpDir set name='@n...', emailaddress='@e...',
PhoneNumber='@p...', department='department' where employeeID='@i...'"

    'Create Command object
        Dim objCommand as OleDbCommand
        objCommand = New OleDbCommand(strSQL, objConnection)



    objCommand.Parameters.Add( New OleDbParameter( "@email",
OleDbType.Varchar, 35 ))
    objCommand.Parameters( "@email" ).Value = "edtemail.text"

    objCommand.Parameters.Add( New OleDbParameter( "@Name",
OleDbType.Varchar, 35 ))
    objCommand.Parameters( "@Name" ).Value = "edtname.text"



    objCommand.Parameters.Add( New OleDbParameter( "@phone",
OleDbType.Integer, 10 ))
    objCommand.Parameters( "@phone" ).Value = "edtphone.text"


    objCommand.Parameters.Add( New OleDbParameter( "@department",
OleDbType.Varchar, 35 ))
    objCommand.Parameters( "@department" ).Value = "edtdepartment.Text"


    objCommand.Parameters.Add( New OleDbParameter( "@id", OleDbType.Integer,
35 ))
    objCommand.Parameters( "@id" ).Value = request.querystring("id")


    objCommand.ExecuteNonQuery()
    objConnection.Close()

    end sub




    </script>
    </head>
    <body>

    <ASP:DataGrid
          id="Results"
          runat="server"
          Width="650"
          BackColor="#ffbd4a"
          BorderColor="black"
          ShowFooter="false"
          CellPadding=3
          CellSpacing="0"
          Font-Name="Verdana"
          Font-Size="8pt"
          AutoGenerateColumns="false"
          EnableViewState="False"
          ShowHeader="true"
          HeaderStyle-BackColor="#e7944a"
          AlternatingItemStyle-BackColor="#eeffee"
          SelectedItemStyle-BackColor="yellow">



    <columns>



      <asp:TemplateColumn runat="server" HeaderText="Employee Name">
    <itemTemplate>

       <form runat="server">
          <table style="background-color: #0eff24;>;
             font: 10pt verdana;border-width:1;border-style:solid;
             border-color:black;" cellspacing=15>
             <tr>
                <td><b>Employee Name</b></td>
                <td>
    <ASP:TextBox id="edtname" runat="server" value='<%#
ontainer.DataItem( "name" )%>'/></td>
             </tr>
             <tr>
                <td><b>Email</b></td>
                <td>
    <ASP:TextBox id="edtemail"   runat="server" value='<%#
Container.DataItem( "emailAddress" )%>'/></td>
             </tr>

         <tr>
                <td><b>Department</b></td>
                <td>
    <ASP:TextBox id="edtdepartment" runat="server" value='<%#
Container.DataItem( "Department" )%>'/></td>
             </tr>

         <tr>
                <td><b>Phone</b></td>
                <td>
    <ASP:TextBox id="edtphone" runat="server" value='<%#
ontainer.DataItem( "PhoneNumber" )%>'/></td>
             </tr>



             <tr>
                <td></td>
                <td><ASP:Button Text="Submit" runat="server"
                       OnClick="Updatedata" /></td>
             </tr>
          </table>

       </form>

     </itemTemplate>
    </asp:TemplateColumn>
    </columns>
    </ASP:DataGrid>
    </body>
    </html>



    --- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 
  --- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



  Return to Index