How to insert data in sqlTable from web pa

Results 1 to 2 of 2

Thread: How to insert data in sqlTable from web pa

  1. #1
    Join Date
    Dec 1969

    Default How to insert data in sqlTable from web pa

    Hi,<BR><BR>Visual Inserting data from Simple web page into sqlTable<BR><BR>I have a very simple question:<BR><BR>1. I have a sql table name tblTest and stored procedure spInsert <BR> Sql table consist of: <BR> 1. TestText – vchar (50)<BR>2. TestNumber – numeric (9)<BR><BR>Web Form:<BR>In Visual created simple web form page <BR>Into the page I include <BR>SqlConenction1;<BR>SqlAdapter1,<BR>SqlCommand1 ,<BR><BR>Two textboxes are added to the page with the names TestText & TestNumber<BR>One click button added – with name Button<BR><BR>Now I need to write a code to the “Button” to activate spInsert.<BR>The final result should be:<BR>When I write something into the two boxes, after when I click the button, the data should be inserted into the sql table.<BR><BR>Thank you in advance!<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: How to insert data in sqlTable from we

    Ok here ya go<BR><BR>&#039;Call this on your button click<BR>Sub insertText(obj as object, e as eventArgs)<BR>&nbsp;&nbsp;Dim myConnection as new SQLConnection("YourConnectionStringGoesHere")<BR>& nbsp;&nbsp;Dim myCommand as new SQLCommand("INSERT INTO tblTest (TestText, TestNumber) VALUES " &theNameOfFirstTextBox.Text &"," &theNameOfSecondTextBox.Text &")", myConnection)<BR><BR>&nbsp;&nbsp;myConnection.Open <BR>&nbsp;&nbsp;myCommand.ExecuteNonQuery<BR>&nbsp ;&nbsp;myConnection.Close<BR>end sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts