Solved

Run Query in VB.Net

Posted on 2004-04-20
7
203 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now