ASP.NET VB forms to SQL Database

ASP.NET VB forms to SQL Database

Page 1 of 1

1 Replies - 3178 Views - Last Post: 22 April 2009 - 02:03 AM Rate Topic: -----

#1 paulyXvpf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 21-April 09

ASP.NET VB forms to SQL Database

Post icon  Posted 21 April 2009 - 07:42 PM

OK, I'm new and pretty freaking lost.

Here is my cheesy little form page:

http://sql-paul.com/press/default.aspx

Created in Visual Web Developer 2005 Express Edition (VB), hosting
on a Windows 2003 Server running SQL Server 2005.

Notice my four text fields and command button.

Notice my test SqlConnect to GridView which shows some sample data
I entered.

The only way I can enter data is by using the the VWD Database Explorer -
Show Table Data. Of course the idea is to get this form page to write data.

My Submit Button code is this:
 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click  

 End Sub 


I think there is code I have to type between the subs.

Here is my schema:

Field Name ------ text field ------ SQL column ----- datatype
*************************************************************
REF NO: txtRefNo refno int
CUSTOMER/CONSUMER: txtCustomer cust varchar
ORDER NUMBER: txtOrderNo ordno int
SUPPLIER (VENDOR): txtSupplier supl varchar

Any ideas or sample code please?

Thanks
Paul

Is This A Good Question/Topic? 0
  • +

Replies To: ASP.NET VB forms to SQL Database

#2 iwan_tjioe82  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 20-April 09

Re: ASP.NET VB forms to SQL Database

Posted 22 April 2009 - 02:03 AM

use this for adding the data
		Using ocon As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")
			ocon.Open()
			Using ocmd As New SqlClient.SqlCommand
				ocmd.Connection = ocon
				ocmd.CommandText = "insert into table1 (refno,cust,ordno,supl) values (" & TextBox1.Text & ",'" & TextBox2.Text & "'," & TextBox3.Text & ",'" & TextBox4.Text & "')"
				ocmd.ExecuteNonQuery()
				ocmd.Dispose()
			End Using
			ocon.Close()
			ocon.Dispose()
		End Using
		TextBox1.Text = ""
		TextBox2.Text = ""
		TextBox3.Text = ""
		TextBox4.Text = ""
		GetData()


explanation Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True is the data source
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1