insert form into sql db via sql

Results 1 to 2 of 2

Thread: insert form into sql db via sql

  1. #1
    Lord+Have+MERCY Guest

    Default insert form into sql db via sql

    this is the code i use to connect it doesnt work:data_source = "driver=(SQL Server);;uid=sa;pwd=;database=TNUserData_Data"<BR> sql_insert = "insert into TNUserData (Name1, Name2, Email, Country, Age, Gender, PostalCode) values (&#039" & Name1 & "&#039, &#039" & Name2 & "&#039, &#039" & Email &"&#039, &#039" & Country &"&#039, &#039" & Age &"&#039, &#039" & Gender &"&#039, &#039" & PostalCode &"&#039)"<BR><BR><BR>&#039create the connection object and opening the database<BR> <BR>Set con = Server.CreateObject("ADODB.connection")<BR>con.Ope n data_source<BR>con.Execute sql_insert<BR><BR>&#039 done...Close the connection!!!<BR><BR>con.Close<BR>Set con = Nothing<BR><BR>this is the error i get:<BR><BR>Error Type:<BR>Microsoft OLE DB Provider for ODBC Drivers (0x80004005)<BR>[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified<BR>/formcollect.asp, line 85<BR><BR><BR>this is what line 85 says:<BR><BR>con.Open data_source<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: insert form into sql db via sql

    Well, to begin with, your connection string has several errors. Try this...<BR><BR>data_source = Provider=SQLOLEDB.1;Persist Security Info=True;Password=;User ID=sa;Initial Catalog=TNUserData_Data;Data Source=yourservername"<BR><BR>Secondly, I would guess that at least one of your data fields (age) is numeric, (and what about postal code?) in which case, you don&#039t use the apostrophes around the value(s) in the sql_insert string.<BR><BR>It would be a good idea to read up a bit on sql!<BR>

Posting Permissions

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