Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Newbie Q: Insert record in db

Reply
Thread Tools

Newbie Q: Insert record in db

 
 
AlecL
Guest
Posts: n/a
 
      02-26-2007
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!!!!!!!!

 
Reply With Quote
 
 
 
 
Mr. SweatyFinger
Guest
Posts: n/a
 
      02-26-2007
yes, but what is calling this procedure?
maybe it really isn't calling it


 
Reply With Quote
 
 
 
 
Jared
Guest
Posts: n/a
 
      02-26-2007
On 26 Feb, 18:12, "AlecL" <(E-Mail Removed)> wrote:
> 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

 
Reply With Quote
 
Mr. SweatyFinger
Guest
Posts: n/a
 
      02-26-2007
try
dim sResult as string
sResult = oOSQL.ExecuteNonQuery()


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      02-26-2007
On Feb 26, 7:12 pm, "AlecL" <(E-Mail Removed)> wrote:
> 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 & "....

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
You cannot add or change a record because a related record is required in table 'lok" André ASP .Net 0 06-25-2006 01:30 PM
How to insert a new record in detailsview when there are no record Frits van Soldt ASP .Net Web Controls 2 11-17-2005 09:18 AM
Retrieving Record Key while creating the record. =?Utf-8?B?SnVzdGlu?= ASP .Net 4 10-05-2004 08:11 PM
insert record using stored proc returns no error but doesn't inserd record ASP General 1 01-09-2004 04:53 PM
" Invalid Disk Table in Boot Record - Boot Record could not be repaired " reply@newsgroup.please Computer Support 2 12-01-2003 05:37 AM



Advertisments