insert data into sql server in vb.net by user input

i want to insert data of vb.net windows application's through form

Page 1 of 1

2 Replies - 75749 Views - Last Post: 21 December 2011 - 12:12 AM Rate Topic: -----

#4 smarty_1201  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 1
  • Joined: 07-October 08

Re: insert data into sql server in vb.net by user input

Post icon  Posted 07 October 2008 - 10:43 PM

I CREATE A WINDOWS FORM TO iNSERT AND SAVE DATA IN SQL SERVER THROUGH UER INPUT USING TOOLS
BUTTON 6 IS THE SAVE BUTTON
===========================================================================================
Imports System.Data
Imports System.Data.SqlClient
Public Class account
	Dim myconnection As SqlConnection
	Dim mycommand As SqlCommand
	Dim dr As SqlDataReader
	Dim dr1 As SqlDataReader
dim ra as integer
 Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
		myconnection = New SqlConnection("server=localhost;uid=sa;pwd=;database=medisam")
		'you need to provide password for sql server
		myconnection.Open()
	   mycommand = New SqlCommand("insert into account([ac],[actype],[msid],[ms]) values ('" & Label9.Text & "','" & ComboBox3.SelectedValue & "','" & ComboBox1.SelectedValue & "','" & ComboBox2.SelectedValue & "')", myconnection)
			   mycommand.ExecuteNonQuery()
		'MessageBox.Show("New Row Inserted" & ra)
		myconnection.Close()
	End Sub
End Class

Was This Post Helpful? 1

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: insert data into sql server in vb.net by user input

Posted 08 October 2008 - 07:40 AM

Do you have a question or problem with the code you posted?
Was This Post Helpful? 1

#6 faceproblems  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-December 11

Re: insert data into sql server in vb.net by user input

Posted 21 December 2011 - 12:12 AM

View Postsmarty_1201, on 07 October 2008 - 10:43 PM, said:

I CREATE A WINDOWS FORM TO iNSERT AND SAVE DATA IN SQL SERVER THROUGH UER INPUT USING TOOLS
BUTTON 6 IS THE SAVE BUTTON
===========================================================================================
Imports System.Data
Imports System.Data.SqlClient
Public Class account
	Dim myconnection As SqlConnection
	Dim mycommand As SqlCommand
	Dim dr As SqlDataReader
	Dim dr1 As SqlDataReader
dim ra as integer
 Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
		myconnection = New SqlConnection("server=localhost;uid=sa;pwd=;database=medisam")
		'you need to provide password for sql server
		myconnection.Open()
	   mycommand = New SqlCommand("insert into account([ac],[actype],[msid],[ms]) values ('" & Label9.Text & "','" & ComboBox3.SelectedValue & "','" & ComboBox1.SelectedValue & "','" & ComboBox2.SelectedValue & "')", myconnection)
			   mycommand.ExecuteNonQuery()
		'MessageBox.Show("New Row Inserted" & ra)
		myconnection.Close()
	End Sub
End Class

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1