|
Not problem maybe you are new here(codeproject),but I am ready to help people
|
|
|
|
|
Try the CString::Format member.
Here is what with ADO and MFC:
CString tempStr;
try {
tempStr.Format("SELECT * "
"FROM CAD_Info "
"WHERE ( ([SessionNumber] = %d) "
"AND ([SiteID] = %d) "
"AND ([SeqNumber] = %d) )",
nSession,nSiteID,nSeqNum);
CMainDataBase::TESTHR(pRst.CreateInstance(__uuidof(Recordset)));
CADORecordSetEx rst(m_pDB,pRst);
rst.Open(tempStr,m_cursorType,m_lockType, adCmdText);
}
catch(CException* e)
{
}
catch (...)
{
}
I know you are using CRecordSet and DAO but the syntax should be similar.
John
|
|
|
|
|
Thanks for the answer,
Unfortunatly I have no experience with ADO, but I have some books to learn it. Maybe I have to do so now;)
BTW, the statemant above ment, this is not the rigth forum too. What would be the right one. In the Lounge ( sorry again), you said, I should try in the MFC-forum, but I can't find.
Thanks, Gerhard
|
|
|
|
|
ensger wrote: this is not the rigth forum too. What would be the right one.
1: Querying the database in the manor you are, your exposing the database to SQL injection attacks. See this article for help distinguishing these attacks.
SQL Injection Attacks[^]
2: Looks like you where suggested to ask this question in the MFC forum was because it’s all string manipulation. Which falls under the purview of MFC CString, although for the purposes here it’s really fine in either forum.
ensger wrote: I should try in the MFC-forum, but I can't find.
Visual C++ / MFC[^]
Good Luck
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Seems to be a very interesting article.
Thaks, Gerhard
|
|
|
|
|
ensger wrote: nfortunatly I have no experience with ADO, but I have some books to learn it.
I recommend ADO if you plan on writing SQL code for connecting to a MS SQL server (or the free version of that) as it is much better at that task and it works well with multithreading which with DAO you have to be very careful.
Although I do not use this code I recommend this class for connecting to ADO databases:
http://www.codeproject.com/database/caaadoclass1.asp[^]
John
|
|
|
|
|
|
Sorry. I was very busy at work. I had 2 doctors in and I had to demo my software to them and I also interviewed someone for a programming position all this while rebuilding a raid array on a linux box.
John
|
|
|
|
|
Thank you for your answer above.
My posting was realy just a question - not a reminder;)
And sometimes I forget, that when I'm working, you may sleep and when I'm sleeping, you may work. That's a problem of internet - you don't recognice the time of others you are speeking to.
Thanks again, Gerhard
|
|
|
|
|
I know this solution is out there somewhere but I have not been able to track it down so here is the situation. I am creating a database and tables dynamically at runtime and I need to verify that the database and table do not already exist on the SqlServer2005 database.
Any takers
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Connect to the master database (which always exists) and check the sysdatabases table (Actually, that might have changed in 2005)
[ADDITIONAL]
It does exist, but as a backwards compatibility option for SQL Server 2000.
The new way is to use the sys.databases view
[/ADDITIONAL]
|
|
|
|
|
From what I have read connecting to the sysdatabases is bad practice as these can change. After a little more research I discovered that in 2.0 there is a connection.getschema method that will return a datatable of the schema of the server. Furthermore, this takes various parameters and to get the database I just have to pass it a string "Databases" to get a table of database names. Rather nifty, maybe Ill write an article.
Aaron
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
USE master<br />
SELECT * FROM sysdatabases WHERE name='DatabaseName'
|
|
|
|
|
Except that way is deprecated in SQL Server 2005 and exists for compatibility with SQL Server 2000.
|
|
|
|
|
Figured it out. With 2005 and .net 2.0 there is a nifty little getSchema method that belongs to the connection property. I can pass it in the parameter "Databases" and it will return a list of databases. Actually rather handy as there are all sorts of information that can be converted to a datatable and iterated through.
Thanks
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
I am developing a web application in c# using visual web developer express.
my database is in SQL server 2000
i created a connection string
<connectionStrings>
<add name="diag" connectionString="Data Source=local;Initial Catalog=diag;Integrated Security=SSPI"/>
</connectionStrings>
then to retrieve in the .cs file i wrote
string connString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["diag"].ConnectionString;
SqlConnection conn = new SqlConnection(connString);
but on compilation i get an error.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Kunal Piyush
|
|
|
|
|
are we not supposed to mention the uid and pwd too i the connection string???
Gautham
|
|
|
|
|
where shud i incorporate the user id and the password.. i checked the machine.config file and cud not find any parameter for the same
moreover the error it is showing is related to sql server 2005.. i am using sql server 2000
Kunal Piyush
|
|
|
|
|
try out by stopping sql 2005 services, may be its because you have both versions installed in your comp??
Gautham
|
|
|
|
|
i m dead sure that i do not have sql 2005 on my comp.. i never installed it.. and double checked it with the control panel..
i only have sql server 2000..now how do i configure to use it with sql 2000
Kunal
|
|
|
|
|
You do not need a user id and password if you specify a secure logon.
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Not if you are using integrated security
only two letters away from being an asset
|
|
|
|
|
Is the server you're trying to connect to called local ? If you want to connect to the local computer (i.e. the one that the client code is running on), you must specify (local) , i.e. with the parentheses.
Specifying (local) also causes the shared memory 'network' library to be used, which can be beneficial if the server does not permit remote connections.
|
|
|
|
|
thanks a lot..
the thing worked..
thats wat i changed
<add name="LocalSqlServer" connectionstring="Data Source=(local);Initial Catalog=diag;Integrated Security=true;" providername="System.Data.SqlClient">
thanks again.
Kunal
|
|
|
|
|
Does any one knows how many records can be inserted/fetched to datatable with in dataset ? I am getting few millions of records from oracle database, and when I use DataAdapter.Fill(dataset) method or Dataset.Tables.Rows.Add(datarow) method i get
"Exception of type System.OutOfMemoryException was thrown." Does any one has idea on this ?
Srinath
|
|
|
|