Newbie Q: Insert record in db

A

AlecL

I am trying to insert a record in a control. All the webcontrols
(i.e. textboxes, ddl, etc.) are also located on the control and the
following code is executing the insert:

Dim oOSQL As New System.Data.SqlClient.SqlCommand("INSERT INTO
FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
topic, comments) VALUES (sName, sEmail, sPhone, eMailTo, EnteredAs,
sTopic, sComments)", Application("Public_DB_Conn"))
oOSQL.Connection.Open()
oOSQL.ExecuteNonQuery()
oOSQL.Connection.Close()

Although the code is not in a try catch block it is not generating any
errors, but it does not enter any data in the db.

Please help!!!!!!!!
 
J

Jared

I am trying to insert a record in a control. All the webcontrols
(i.e. textboxes, ddl, etc.) are also located on the control and the
following code is executing the insert:

Dim oOSQL As New System.Data.SqlClient.SqlCommand("INSERT INTO
FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
topic, comments) VALUES (sName, sEmail, sPhone, eMailTo, EnteredAs,
sTopic, sComments)", Application("Public_DB_Conn"))
oOSQL.Connection.Open()
oOSQL.ExecuteNonQuery()
oOSQL.Connection.Close()

Although the code is not in a try catch block it is not generating any
errors, but it does not enter any data in the db.

Please help!!!!!!!!

Hi

Assuming that sName, sEmail, etc are controls, you need to concatenate
their values into your string.

e.g. VALUES(" + sName.Text + ", " + sEmail.Text + ", ....

Cheers

Jared
 
G

Guest

I am trying to insert a record in a control. All the webcontrols
(i.e. textboxes, ddl, etc.) are also located on the control and the
following code is executing the insert:

Dim oOSQL As New System.Data.SqlClient.SqlCommand("INSERT INTO
FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
topic, comments) VALUES (sName, sEmail, sPhone, eMailTo, EnteredAs,
sTopic, sComments)", Application("Public_DB_Conn"))
oOSQL.Connection.Open()
oOSQL.ExecuteNonQuery()
oOSQL.Connection.Close()

Although the code is not in a try catch block it is not generating any
errors, but it does not enter any data in the db.

Please help!!!!!!!!

at least

"INSERT INTO
FeedBackAndTales (name, email, daytimephone, sentToEmail, EnteredAs,
topic, comments) VALUES ('" & sName & "', '" & sEmail & "....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top