Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute SQL statment error in MySQL

Status
Not open for further replies.

chicagoborn

Programmer
Feb 22, 2005
1
US
I have been coding web-based forms with MSAccess and MSSQL backends using VBScript and ASP for a LONG time.

However, this is my first try with MySQL, and I'm stumped! argh...!!!

I have a web-based form with 26 fields inserting into one (1) table.
Not all fields are necessary, and all unneccesary fields are set to allow null values.

I used Response.Write to check my variables and the SQL statement. I tested the query using the PHPMyAdmin (by cutting and pasting the Response.Write) and the data was added to the table correctly.

Here's my dilemma. When I remove the Response.Write and insert objConn.Execute(SQLstmt), the data is inserted into the table but the page does not reload (the page is submits back to itself and page states are determined by the value of btnSubmit). The browser just sits and spins. If I stop the page from loading and try to open another ASP page, the browser just sits and spins. Eventually, everything stops spinning and I can access ASP pages again.

Obviously, by SQL statment and Database connection are correct; so what's the hang up?

Any help will be appreciated,
Chicagoborn

Code:

'**Create connection to database and insert data into table
'**Variables for connection
Dim objConn, SQLstmt
Set objConn = Server.CreateObject("ADODB.Connection")

'**Connection
connString = "driver={MySQL};server=localhost;uid=xxxx;pwd=xxxx;database=xxxx"
objConn.open connString

'**Insert data into table

SQLstmt = "INSERT INTO tblContacts(title, first_name, last_name, church, street_address, city, state, zip, mailing_address, office_phone, home_phone, cell_phone, email, web_site, regional_contact, gibm_missionary, field, endorsed, status, arrived, ministry, sending_church, regional_state, notes, sending_church_location)
SQLstmt = SQLstmt & " VALUES ("
SQLstmt = SQLstmt & "'" & title & "',"
SQLstmt = SQLstmt & "'" & first_name & "',"
SQLstmt = SQLstmt & "'" & last_name & "',"
SQLstmt = SQLstmt & "'" & church & "',"
SQLstmt = SQLstmt & "'" & street_address & "',"
SQLstmt = SQLstmt & "'" & city & "',"
SQLstmt = SQLstmt & "'" & state & "',"
SQLstmt = SQLstmt & "'" & zip & "',"
SQLstmt = SQLstmt & "'" & mailing_address & "',"
SQLstmt = SQLstmt & "'" & office_phone & "',"
SQLstmt = SQLstmt & "'" & home_phone & "',"
SQLstmt = SQLstmt & "'" & cell_phone & "',"
SQLstmt = SQLstmt & "'" & email & "',"
SQLstmt = SQLstmt & "'" & web_site & "',"
SQLstmt = SQLstmt & "'" & contact & "',"
SQLstmt = SQLstmt & "'" & missionary & "',"
SQLstmt = SQLstmt & "'" & field & "',"
SQLstmt = SQLstmt & "'" & endorsed & "',"
SQLstmt = SQLstmt & "'" & status & "',"
SQLstmt = SQLstmt & "'" & arrived & "',"
SQLstmt = SQLstmt & "'" & ministry & "',"
SQLstmt = SQLstmt & "'" & sending_church & "',"
SQLstmt = SQLstmt & "'" & contact_state& "',"
SQLstmt = SQLstmt & "'" & notes& "',"
SQLstmt = SQLstmt & "'" & sending_church_location & "'"
SQLstmt = SQLstmt & ")"'
Response.Write ""&SQLstmt&""
objConn.Execute(SQLstmt)

'**Close
objConn.Close
Set objConn = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top