|
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
|
|
|
|
|
Thank you.It's OK now
But why does it work only when i cut the path,just write: L"...;Data Source=list.mdb;" ?Otherwise,it will append the path where the application locate,then cause a "can't find file" error.
God blessing me...
|
|
|
|
|
I have DataAdapter and DataSet,my dataadapter string is something like this:
"SELECT * FROM TABLE",and I fill dataset with this dataadapter,and I bound Datgrid to it and it's ok.
Now after this I want to set a filter for the recorsets that datagrid show.Can I use those dataadapter and dataset and set the filter in the way that I don't know it,
or I HAVE TO fill dataadapter and dataset from the beginning with new SQL 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
|
|
|
|
|
To filter your table:
1) Get the DataView from the appropiate table.
MyTable.DefaultView //this is a property of the table.
2) Set the Filter.
MyTable.DefaultView.RowFilter = "Name = 'Mazdak'";
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
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
|
|
|
|
|
I used this code :
string str="CompanyName LIKE '%"+DropDownList1.SelectedItem.Text+"'";
ds.Tables["Customers"].DefaultView.RowFilter=str;
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
I have a drop down list box,it's item form A to Z,when user choose one,data grid must filter by the words that their first character are like that.when I use this code nothing
happen,did I miss something?
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
|
|
|
|
|
According to the code above you are matching results where the last letter is the one selected :-P
string str="CompanyName LIKE '"+DropDownList1.SelectedItem.Text+"%'"; is the correct version
Hopefully that is what is causing the problem, because according to the docs what you have should work.
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:
Hopefully that is what is causing the problem, because according to the docs what you have should work.
No ,that was not the problem.
It seems that datagrid does not update.
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
|
|
|
|
|
hmmmm, I'll have to get back with you tomorrow; my brain has shut-down for the night
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
|
|
|
|
|
I agree with James on this:
string str="CompanyName LIKE '"+DropDownList1.SelectedItem.Text+"%'"; is the correct version
where do you have that code, in what event ?.
I assume you know if DropDownList changes the filter will not do it automatically.
sorry if this is too obvious.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I need a SQL statement which retreive all strings start with special charachter.
For example all words start with 'M' in recordserts.
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
|
|
|
|
|
SELECT X FROM Y WHERE X LIKE 'M%'
Omer.
|
|
|
|
|
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
|
|
|
|
|
Here is the sql stmt
SELECT * FROM <tablename> WHERE Name like 'M%'
Sjt
From Heaven
|
|
|
|
|
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
|
|
|
|
|
I'm trying to page a recordset, but in one case I have a problem. The code looks like:
<br />
sSQL = "SELECT Table1.*, Table2.* " &_<br />
"FROM Table1 LEFT JOIN Table2 ON Table1.Name = Table2.Name"<br />
rec.CursorLocation = adUseClient<br />
rec.CacheSize = 25<br />
rec.PageSize = 25<br />
rec.Open sSQL, con, adOpenForwardOnly, adLockReadOnly<br />
In case that the Table1.Name exists in Table2.Name, all is working correct. But if not... I'm getting E_FAIL from Microsoft Cursor Engine when I'm trying to do anything with returned Recordset. Though without paging and having a client cursor, it works fine.
Any ideas what is going on and how to fix it?
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
|
Hi,
When i try to install DAO components (Jet 3.5) on Windows NT WorkStation or Server, the following error message appear:
Another application is currently using JET file, close all applications and continue.
I try to follow the resolution method ( Q169497 ) to resolve this problem but it don't work.
Anybody can help me to solve this problem?
Thanks in advance
Cheickna
|
|
|
|
|