473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

.exe to insert data in SQLServer database

How can I make an .exe file that can insert data automatically in a
SQLServer database, I can do it in C, but how can I connect to SQLServer
and execute a query.

All data that I have to insert are data that I can have from PC
environment variables.

Thanks
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 20 '05 #1
2 2831
ADO or ADO.NET is the API most commonly used to connect to SQLServer from
C++ and other languages. You can use the ADO Command object to execute any
SQL statement, including INSERT statements to insert new data. Lookup ADO in
SQL Server Books Online for some examples.

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2
Hi

There are various ways to do this if you want to look at a programming
language such as VB then check out the examples that come with the SQL
Server installation. If you want a simple way to do it then you could use
the osql/isql utilities that are shipped with SQL Server. Check out books
online for information on all of these things. An example using osql on the
command line to access environment variables:

C:\>set Name=Fred

C:\>echo %name%
Fred

C:\>osql -E -dTest -S"(local)" -Q"CREATE TABLE Tmp1 ( name varchar (20) )"

C:\>osql -E -dTest -S"(local)" -Q"INSERT INTO Tmp1 ( name ) VALUES (
'%Name%' )
"
(1 row affected)

C:\>osql -E -dTest -S"(local)" -Q"SELECT * FROM Tmp1 "
name
--------------------
Fred

(1 row affected)

You could also put this into a batch file.

If you are looking to import data in bulk then look at the bcp utitlity or
the BULK INSERT statement.

John

"Santo Santis" <sa********@supereva.it> wrote in message
news:94*************************************@mygat e.mailgate.org...
How can I make an .exe file that can insert data automatically in a
SQLServer database, I can do it in C, but how can I connect to SQLServer
and execute a query.

All data that I have to insert are data that I can have from PC
environment variables.

Thanks
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jan van Veldhuizen | last post by:
I try to use the Server Data on Insert property to return a column value swhich is set in a trigger. But it does not work. Why not? What am I doing wrong? (BTW I'm using Oracle version 10) My...
2
by: schumacker | last post by:
Hi everyone! I am working with Delphi v7 and MS SQLServer. I am trying to insert data in a table with a SQL sentence. Some of the fields of my table are type char or varchar, and they can have...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
1
by: =?Utf-8?B?VGFudGFsdXM=?= | last post by:
Hello All: I am using a the following code to insert some values into CE edition database running on the Desktop.This code works fine as far as inserting the new record the problem arises after...
4
by: Rick | last post by:
I've moved code from a stage machine to the production machine, exact same code works fine on the stage machine, they are both windows 2003 servers, I'm getting a "Cannot generate SSPI context"...
1
by: mark mestrom | last post by:
Hi all, i have a problem. In my access-application i am trying to insert a record in a linked table with resides in a sqlserver 2000 database. However, the primary key in that table is an INT with...
4
by: =?Utf-8?B?U2FpbXZw?= | last post by:
Hello to all. Please help me. I'm inserting a date into sqlserver 2005 using C#3. my problem is while insert is successfull my date and time. It's possible to insert only a date? -- To be...
1
by: rekhasc | last post by:
i am using the database SQLSERver 2005, i m new to this i worked in sql server2000... but using sqlserver 2005 i dont know how to insert the values... i write the code but the values is not storing...
7
by: anu b | last post by:
Hi I need to use Clr trigger for insert command My code is as below I am using SQL server 2005 and VS 2008.... but after running this code i didnt get the result as i expexted it shows the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.