Solved

Run Query in VB.Net

Posted on 2004-04-20
7
206 Views
Last Modified: 2010-04-24
hi,

I am writing a windows application and need to run an update or append query from a button on my form.

I have two table, tblEmp1, tblEmp2 , both has 3 similar fields, EmpID, EmpName and EmpDept,

1. I Need to Update tblEmp2 from tblEmp1, but with a click of a button on my form

2. Same as above but need to run appned query,

both of my tables are on Access database,

Please give me hard code and detials how to do it.

thankx
0
Comment
Question by:nibirkhan
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:malharone
ID: 10872454
       Dim conn As New SqlClient.SqlConnection("YOUR_CONNECTION_STRING")

        Dim sc As SqlClient.SqlCommand = conn.CreateCommand()
        sc.CommandText = "update your_table set column1='hello', column2='world'"

        sc.ExecuteNonQuery()
0
 
LVL 2

Author Comment

by:nibirkhan
ID: 10873618
Sorry, My tables are in Access database not on SQl server
0
 
LVL 9

Expert Comment

by:malharone
ID: 10873667

        Dim conn As New System.Data.OleDb.OleDbConnection("YOUR_CONNECTION_STRING")
        Dim sc As OleDb.OleDbCommand = conn.CreateCommand()
        sc.CommandText = "update your_table set column1='hello', column2='world'"

        sc.ExecuteNonQuery()
0
 
LVL 2

Author Comment

by:nibirkhan
ID: 10880683
nope, I guess it's not the thing I am wanting, why do I have to insert value inside my query, I want to Merge those two tables with a click of a button without having repeated value, that's why I guess I need an unoin query...

thanks
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 11094326
INSERT INTO tblEmp1
SELECT tblEmp2.*
FROM tblEmp2
WHERE EmpID Not In (Select EmpID From tblEmp1

Bob
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question