• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Run Query in VB.Net

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
nibirkhan
Asked:
nibirkhan
  • 2
  • 2
1 Solution
 
malharoneCommented:
       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
 
nibirkhanAuthor Commented:
Sorry, My tables are in Access database not on SQl server
0
 
malharoneCommented:

        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
 
nibirkhanAuthor Commented:
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
 
Bob LearnedCommented:
INSERT INTO tblEmp1
SELECT tblEmp2.*
FROM tblEmp2
WHERE EmpID Not In (Select EmpID From tblEmp1

Bob
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now