Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 131,708 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,396 people online right now. Registration is fast and FREE... Join Now!




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

 
Reply to this topicStart new topic

insert data into sql server in vb.net by user input, i want to insert data of vb.net windows application's through form

smarty_1201
post 7 Oct, 2008 - 09:43 PM
Post #1


New D.I.C Head

*
Joined: 7 Oct, 2008
Posts: 1

I CREATE A WINDOWS FORM TO iNSERT AND SAVE DATA IN SQL SERVER THROUGH UER INPUT USING TOOLS
BUTTON 6 IS THE SAVE BUTTON
================================================================================
===========
CODE
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
User is offlineProfile CardPM

Go to the top of the page

Jayman
post 8 Oct, 2008 - 06:40 AM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,827



Thanked 38 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Do you have a question or problem with the code you posted?
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 09:28AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month