Adding to a Database

Results 1 to 3 of 3

Thread: Adding to a Database

  1. #1
    Shardool Karnik Guest

    Default Adding to a Database

    I want to add a record to a data base. I get an error with the code I use. Just show me the first few basic statements to Open the Database to be able to add using AddNew or something.

  2. #2
    Join Date
    Dec 1969

    Default RE: Adding to a Database

    I&#039d recommend that you skip using AddNew and use SQL statements, instead.<BR><BR>&#060;%<BR>Dim objCon<BR>Dim strSQL<BR><BR>strSQL="INSERT INTO MyTable(NumericField1,TextField2) " & _<BR>"Values(1234,&#039test&#039)"<BR>Set objCon=Server.CreateObject("ADODB.Connection")<BR> objCon.Open &#039(supply your DSN or other connection string here)<BR>objCon.Execute strSQL<BR>objCon.Close<BR>Set objCon=Nothing<BR>%&#062;<BR><BR>With that code, you have executed a SQL INSERT statement, which is more efficient than opening a recordset and adding a record to it. Note how numeric and text entries are treated differently.<BR><BR>Kurt

  3. #3
    Shardool Karnik Guest

    Default RE: Adding to a Database

    Hey thanks kurt....I will look into this...<BR>Where can I find something on SQL ? I am a beginner for ASP and I want to start just with the right stuff so later I don&#039t have a problem....well this is what I found for SQL<BR><BR>Do you think its the perfect Tutorial/Reference ?

Posting Permissions

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