|
Andres Manggini wrote:
1) Create an instance of the CDatabase object, this object represents a connection to the Database (See method Open to set the Connection String)
2) Instanciate your Recordset with the CDatabase object already Constructed
3) Call Open on the Recordset using the corresponding SQL Statement.
And then I call another method to get the data?
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Mazdak has post a very clear sample here (as a response to your message)
http://www.codeproject.com/script/comments/forums.asp?forumid=1725&select=135665&tid=135655#xx135665xx
you can see right there how to create the database, create the recordset, open it, and get data out of it.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Rickard Andersson wrote:
And then I call another method to get the data?
With GetFieldValue() you can get the specific column value in a specific ROW,to move in the rows you can use Move(),MoveNext(),MovePrev() and ....
Hope thats help.Any other question?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
|
ODBC driver of Progress is installation very difficult. and I don't advice using ODBC direver for progress..
best regards.
MFC
|
|
|
|
|
Okay, SQL is a "language".... and SQL Server is what??
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Microsoft SQL Server is a database management program that understands the SQL language (like any other proper DBMS).
|
|
|
|
|
Hi All,
I've come in after the weekend to discover that my SQL Server instance (running some new software we've written) has climbed in memory usage a lot more than I'd expect. I'm checking all of the cursors and XML documents used for leaks, but what I'd really like is a tool to track allocations of resources such as these, to tell me straight out where the problem is. I'm sure this must exist... can someone point me in the right direction?
Thanks!
|
|
|
|
|
SQL Server will try to keep everything in memory it can, so thats why you see a memory usage increase. First, to answer your question, run perfmon, and check out the performance counters from the SQLServer:Memory Manger performance object. If you'd like to set a maximum limit for memory usage go into SQL Enterprise Manager, right click your server and go to properties. On the memory tab slide the maximum bar down to a number you are comfortable with.
Andy Gaskell, MCSD MCDBA
|
|
|
|
|
|
I'm trying to determine a primary key of some table in MS Access 2000 database. Didn't succeeded so far. Tried to use ADO schemas, ADOX..
In ADOX I got all indexes with PrimaryKey property set to true
Anyway to determine a primary key in table?
This is for ASP actually, but I I'll get it work in C++ - good too
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
I'm moving over to ADO.NET and have read some tutorials and examples but really need a good book to learn from. I've seen a number of them out there but which ADO.NET books would you say are the better of the crop ???
Thanks in advance,
Travis D. Mathison ---
--- After three days without programming, life becomes meaningless ...
|
|
|
|
|
Whats wrong with this code?(it's in ASP.NET)
OleDbConnection myConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Inetpub\wwwroot\First\Testing.MDB");
myConnection.Open();
OleDbDataAdapter myAdapter=new OleDbDataAdapter("SELECT * FROM Table2",myConnection);
OleDbCommandBuilder myBuild=new OleDbCommandBuilder(myAdapter);
DataSet myDataSet=new DataSet();
myAdapter.Fill(myDataSet,"Table2");
DataColumn[] keys=new DataColumn[1];
keys[0]=myDataSet.Tables["Table2"].Columns["Username"];
myDataSet.Tables["Table2"].PrimaryKey=keys;
DataRow findRow=myDataSet.Tables["Table2"].Rows.Find(TextBox3.Text);
if(findRow==null)
{
if(TextBox1.Text==TextBox2.Text)
{
DataRow myRow=myDataSet.Tables["Table2"].NewRow();
myRow["Username"]=TextBox3.Text;
myRow["Password"]=TextBox2.Text;
myDataSet.Tables["Table2"].Rows.Add(myRow);
myAdapter.Update(myDataSet,"Table2");
}
}
I got an unhandled exception for this line:myAdapter.Update(myDataSet,"Table2");
Syntax error in INSERT INTO statement.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I'm not sure but you may have to assing the Insert, Update, and Delete Commands to the DataAdapter; at least thats what my Beginning ASP.NET book shows being done, but it was based on Beta 2.
If that doesn't work can you tell me the value of myAdapter.UpdateCommand.CommandText ?
It also looks like for using the CommandBuilder you have to specify fields to get (including the primary key fields if they exist) because the other commands are built without accessing the database.
I'm basing this on what I see in the book, shame on me
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Hi James:
I learn ASP.NET like a blind persons,because in my country there is no books about .net topics and I have only some limited internet resources ,Any way.
James T. Johnson wrote:
I'm not sure but you may have to assing the Insert, Update, and Delete Commands to the DataAdapter;
How should I do it?
James T. Johnson wrote:
If that doesn't work can you tell me the value of myAdapter.UpdateCommand.CommandText?
I don't know how to debug ASP.NET application In the windows form I put a breakpoint and use F5,But here it does not work
Thanks
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Mazdak wrote:
I learn ASP.NET like a blind persons,because in my country there is no books about .net topics and I have only some limited internet resources
I've always considered myself lucky in that regard I only mentioned it came from the book because I hadn't actually tried it myself.
Mazdak wrote:
James T. Johnson wrote:
I'm not sure but you may have to assing the Insert, Update, and Delete Commands to the DataAdapter;
How should I do it?
OleDbDataAdapter myAdapter=new OleDbDataAdapter("SELECT Username, Field1, Field2, .... FROM Table2",myConnection);
OleDbCommandBuilder myBuild=new OleDbCommandBuilder(myAdapter);
myAdapter.InsertCommand = myBuild.GetInsertCommand();
myAdapter.UpdateCommand = myBuild.GetUpdateCommand();
myAdapter.DeleteCommand = myBuild.GetDeleteCommand();
DataSet myDataSet=new DataSet();
myAdapter.Fill(myDataSet,"Table2");
[....]. Mazdak wrote:
I don't know how to debug ASP.NET application,In the windows form I put a breakpoint and use F5,But here it does not work
At the top of your ASP.NET page change your Page tag to this <%@ Page Trace="true" ....>
Now when you want to output something for debugging purposes use, Trace.Write(strCategoryName, strValueToOutput); The category name is so that you can see what the value is for.
In your case you would put this before the myAdapter.Update(myDataSet,"Table2");
Trace.Write("myAdapter.InsertCommand.CommandText", myAdapter.InsertCommand.CommandText);
HTH, I'm was just on my way to bed so my brain may be fried :-P
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Good morning;)
James T. Johnson wrote:
OleDbDataAdapter myAdapter=new OleDbDataAdapter("SELECT Username, Field1, Field2, .... FROM Table2",myConnection);OleDbCommandBuilder myBuild=new OleDbCommandBuilder(myAdapter);myAdapter.InsertCommand = myBuild.GetInsertCommand();myAdapter.UpdateCommand = myBuild.GetUpdateCommand();myAdapter.DeleteCommand = myBuild.GetDeleteCommand();
I got really nice unhandled exception for last two line :
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
And after I use that still the same problem remain(it could not update)
James T. Johnson wrote:
// these lines shouldn't be needed anymore because we explicitly defined the fields above// DataColumn[] keys=new DataColumn[1];// keys[0]=myDataSet.Tables["Table2"].Columns["Username"];// myDataSet.Tables["Table2"].PrimaryKey=keys;
I need these lines because I use Find method and I need primary key for it.
James T. Johnson wrote:
At the top of your ASP.NET page change your Page tag to this <%@ Page Trace="true" ....>
Now when you want to output something for debugging purposes use, Trace.Write(strCategoryName, strValueToOutput); The category name is so that you can see what the value is for.
In your case you would put this before the myAdapter.Update(myDataSet,"Table2");
Trace.Write("myAdapter.InsertCommand.CommandText", myAdapter.InsertCommand.CommandText);
I did as you say and nothing appear in output window,also something that I can't describe it mess up the background of page?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Mazdak wrote:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
Did your SELECT statement specify fields or just *?
When using the CommandBuilder you have to specify the fields that you are using, otherwise it has no way of generating the Update or Insert commands (since both require you to specify fieldnames and values).
Mazdak wrote:
I need these lines because I use Find method and I need primary key for it.
OK, I see what the code is actually doing now; I was thinking it was adding new columns to the data table when its just telling what the primary keys are. My bad
Mazdak wrote:
I did as you say and nothing appear in output window,also something that I can't describe it mess up the background of page?
When you enable tracing you should see a large table that shows what happened as the page was processed. I can't explain what the output should be like, but I can show you I've uploaded a page that shows the output from a simple webform that sets the text of a label control inside the page_load. I've added Trace.Write's just before and just after I change the text.
http://www.takklesoft.com/dotnet/tracing_results.htm
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
James T. Johnson wrote:
Did your SELECT statement specify fields or just *?
I specify fields
And after tracing InsertCommand it show me this:
myAdapter.InsertCommand.CommandText INSERT INTO Table2( UserName , Password ) VALUES ( ? , ? )
I use these code for inserting:
DataRow myRow=myDataSet.Tables["Table2"].NewRow();
myRow[0]=TextBox3.Text;
myRow[1]=TextBox2.Text;
myDataSet.Tables["Table2"].Rows.Add(myRow);
Then why it doesn't know the values for insertation?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Very odd, you've done just about what the book is showing being done; except you've used text boxes for input and they used literal values (which won't make a difference since they are both string objects being assigned to the elements of myRow.)
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Soryy James,I can't understand what are you talking about?
(Forgive me for my poor english)
You mean I made mistake somewhere?You ask me a question or you give me advise;)????
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Mazdak wrote:
You mean I made mistake somewhere?You ask me a question or you give me advise????
Neither
I just said that what you did is almost the same as the code in my ASP.NET book. The code *should* work, but obviously isn't.
Its starting to get that time though, so I'll have to take a look at it whenever I get up out of bed :-P
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
hmmmm,Now I got what you say
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
(In VC6.0,using MFC & ADO)
I wrote a application based on MicroSoft Access.To let users use my application more easily,i want to save them from setting a DSN in Control Panel ODBC Administrator by themselves.Now suppose i have a Access file called List.mdb located in C:\,it contains just one table called Toys,and i created a ADO smart pointer in my code:
_ConnectionPtr m_pConnection;
Then,what the ConnectionString of m_pConnection shall look like? Or there's some other good method?
Thanks Much
God blessing me...
|
|
|
|
|
Allis wrote:
Then,what the ConnectionString of m_pConnection shall look like?
m_pConnection->Open(
_bstr_t(L"Provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\file.mdb;"),
_bstr_t(L""),
_bstr_t(L""),
adModeUnknown);
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|