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
 
A

Alexey Smirnov

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 & "....
 
Top