Updating multiple records

Results 1 to 2 of 2

Thread: Updating multiple records

  1. #1
    Join Date
    Dec 1969

    Default Updating multiple records

    In am making the transition from ASP to ASP.NET.<BR><BR>Updating multiple records used to be easy... I have researched method with ASP.NET and nothing is working. Could anyone give me a simple solution in ASP.NET to mock this ASP code.<BR><BR>Assume:<BR>Conn is the ADODB Connection<BR>RS is the ADODB Recordset<BR>siteIT, siteName, siteLocation are variables with values to be inserted to their respective database fields as shown below.<BR><BR>SQL = "Select * FROM Site"<BR>RS.Open, SQL, Conn, 1,3,0<BR><BR>RS.AddNew<BR>RS("SiteID") = siteID<BR>RS("SiteName") = siteName<BR>RS("SiteLocation") = siteLoc<BR>RS.Update<BR><BR>RS.Close<BR><BR><BR>Si gned, <BR>NotFond Of ADO.NET<BR><BR><BR><BR><BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Try this ..

    If you are using SQL Server:<BR><BR>Dim Conn as SQLConnection<BR>Dim Sql as String<BR>Dim CmdInsert as SQLCommand<BR><BR>Conn = New SQLConnection("server=YourServer;uid=YourUser;pwd= YourPassword;database=YourDatabase")<BR><BR>SQL = "INSERT INTO Site (siteid,SiteName, SiteLocation) Values (@siteid, @sitename, @SiteLocation)"<BR><BR>CmdInsert = New SQLCommand(SQL, Conn)<BR>CmdInsert.parameters.add("@siteid", SiteID)<BR>CmdInsert.parameters.add("@SiteName", SiteName)<BR>CmdInsert.parameters.add("@siteLocati on", SiteLoc)<BR><BR>Conn.open()<BR>CmdInsert.ExecuteNo nQuery<BR>Conn.Close()<BR><BR>Remember to import system.data.sqlclient and system.data namespaces<BR><BR>If you are using Access you will need to lookup OledbConnection, OleDbCommand etc.<BR><BR>I haven&#039;t been using .NET for long but I think its great - buy yourself asp.net unleashed as it has a good chapter on ADO.NET.<BR><BR>Hope this helps<BR><BR>Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts