Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Inserting a Record Into SQL

Reply
Thread Tools

Inserting a Record Into SQL

 
 
Justin Musick
Guest
Posts: n/a
 
      10-30-2003
I'm having some trouble inserting a record into a SQL database from a simple
form. When the "txtName" text box is filled and the button is clicked, I
get no error but no record is added to the database.

My code is:

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click

Dim insertCmd As String = "INSERT INTO tblCustomer (cusName) VALUES
(@cusName)"

Dim insertWO As SqlCommand

daWO.Fill(DsWO1)

insertWO = New SqlCommand(insertCmd, cnnWO)

insertWO.Parameters.Add(New SqlParameter("@cusName", SqlDbType.NVarChar,
50))

insertWO.Parameters("@cusName").Value = txtName.Text

insertWO.Connection.Open()

'Sends user to success page once data successfully is entered

Response.Redirect("wosuccess.htm")

End Sub


 
Reply With Quote
 
 
 
 
H Branyan
Guest
Posts: n/a
 
      10-30-2003
after opening the connection,

insertWO.ExecuteNonQuery()


--
[[((hillarie))]]

To reply by email, remove ".SPAMBLOCK" from email address



"Justin Musick" <(E-Mail Removed)> wrote in message
news:3fa12b3e$0$71480$(E-Mail Removed) m...
> I'm having some trouble inserting a record into a SQL database from a

simple
> form. When the "txtName" text box is filled and the button is clicked, I
> get no error but no record is added to the database.
>
> My code is:
>
> Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnSubmit.Click
>
> Dim insertCmd As String = "INSERT INTO tblCustomer (cusName) VALUES
> (@cusName)"
>
> Dim insertWO As SqlCommand
>
> daWO.Fill(DsWO1)
>
> insertWO = New SqlCommand(insertCmd, cnnWO)
>
> insertWO.Parameters.Add(New SqlParameter("@cusName", SqlDbType.NVarChar,
> 50))
>
> insertWO.Parameters("@cusName").Value = txtName.Text
>
> insertWO.Connection.Open()
>
> 'Sends user to success page once data successfully is entered
>
> Response.Redirect("wosuccess.htm")
>
> End Sub
>
>



 
Reply With Quote
 
 
 
 
Justin Musick
Guest
Posts: n/a
 
      10-31-2003
You're the man, thanks much!

jM

"H Branyan" <(E-Mail Removed)> wrote in message
news:bnrbt6$14ik4e$(E-Mail Removed)-berlin.de...
> after opening the connection,
>
> insertWO.ExecuteNonQuery()
>
>
> --
> [[((hillarie))]]
>
> To reply by email, remove ".SPAMBLOCK" from email address
>
>
>
> "Justin Musick" <(E-Mail Removed)> wrote in message
> news:3fa12b3e$0$71480$(E-Mail Removed) m...
> > I'm having some trouble inserting a record into a SQL database from a

> simple
> > form. When the "txtName" text box is filled and the button is clicked,

I
> > get no error but no record is added to the database.
> >
> > My code is:
> >
> > Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles btnSubmit.Click
> >
> > Dim insertCmd As String = "INSERT INTO tblCustomer (cusName) VALUES
> > (@cusName)"
> >
> > Dim insertWO As SqlCommand
> >
> > daWO.Fill(DsWO1)
> >
> > insertWO = New SqlCommand(insertCmd, cnnWO)
> >
> > insertWO.Parameters.Add(New SqlParameter("@cusName", SqlDbType.NVarChar,
> > 50))
> >
> > insertWO.Parameters("@cusName").Value = txtName.Text
> >
> > insertWO.Connection.Open()
> >
> > 'Sends user to success page once data successfully is entered
> >
> > Response.Redirect("wosuccess.htm")
> >
> > End Sub
> >
> >

>
>



 
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
Inserting record into postgresql database Meszaros, Stacy Python 0 03-11-2011 10:08 PM
Inserting a new record into a collection in a action form from a jsp simon_s_li@hotmail.com Java 1 10-13-2007 10:48 PM
problems inserting into sql using SqlHelper.ExecuteScalar Chad Dittmer via .NET 247 ASP .Net 1 09-15-2004 06:57 PM
ASP.Net bug when inserting Blobs into SQL Server? .Net Newbie ASP .Net 0 08-24-2004 09:09 PM
Inserting dates into SQL Server DB Andrew Banks ASP .Net 11 01-07-2004 12:24 AM



Advertisments