Solved

Run Query in VB.Net

Posted on 2004-04-20
7
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

728 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