[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Inserting data in non-standerd way

David T Besselievre

1/23/2003 5:00:00 PM


I currently have an application in C++ that will insert
data using the following query.

if exists(select 1 from rtocsvBidsMarket
where DateTime = ?)
update rtocsvBidsMarket set MW1 = ?, Bid1 = ?, SLP1 = ?
where DateTime = ?
else
insert rtocsvBidsMarket (DateTime, MW1, Bid1, SLP1)
values (?, ?, ?, ?)

To perform the query I first have to populate data
structure with all of the data and I tell the application
how to mapp the datastructure to the above query.

Is there a way to do this in C#? What more is there a
good book that I can get that will help in this area? The
book that I have only covers working with Access and I
need one that will go over SQL 2000.
1 Answer

(Hussein Abuthuraya(MSFT))

1/23/2003 9:35:00 PM

0

Hi David,

The following sample is from the ODBC.NET documentation:

public void CreateMyOdbcCommand(OdbcConnection myConnection,
string mySelectQuery, OdbcParameter[] myParamArray) {
OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
myCommand.CommandText = "SELECT CustomerID, CompanyName FROM Customers WHERE Country = ? AND City = ?";
myCommand.Parameters.Add(myParamArray);
for (int j=0; j<myParamArray.Length; j++)
{
myCommand.Parameters.Add(myParamArray[j]) ;
}
string myMessage = "";
for (int i = 0; i < myCommand.Parameters.Count; i++)
{
myMessage += myCommand.Parameters[i].ToString() + "\n";
}
MessageBox.Show(myMessage);
}

I hope it helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.co....