|
Luc Pattyn wrote: a simple
writer.Write(format, args) would have been sufficient.
indeed it would.
|
|
|
|
|
That was it, well spotted! many Thanks
All working now! I just wanted to create library routines that render html to a StringBuilder or a HtmlTextWriter for duplicate rendering in ServerControls. Works out really well
|
|
|
|
|
Did you look at the value of format when the problem occurred?
Did you check args had a sufficient number of elements for it?
If so, why didn't you tell us their values?
Did you check at what exact line the exception occurs?
- an exception holds line information, you get to see it when you call Exception.ToString()
(but not when using Exception.Message).
- any half-decent IDE can display line numbers; to turn this on in Visual Studio, go to menu
Tools/Options/TextEditor/AllLanguages
|
|
|
|
|
Hello everyone,
I want to monitor the Http traffic (request and response) from IE on my local computer to some specific web site, I am especially interested in the special headers IE added in the communication.
Any tools to use? Are there any existing tools from Visual Studio?
thanks in advance,
George
|
|
|
|
|
|
Great, J4amieC!
I like this!
regards,
George
|
|
|
|
|
Hi Guys. I'm trying to add a column to an existing DataTable. When running the code I don't get no error message or anything but when checking the Table the column has not been added. Any ideas why?
Below the test code.
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = T:\Nasmeea\PSSZ.mdb";
conn.Open();
DataAdapter = new OleDbDataAdapter("Select * From [DivInfo]", conn);
DataTable dataTable = new DataTable("DivInfo");
DataColumn dValue = new DataColumn();
DataColumn dMember = new DataColumn();
dValue.ColumnName = txtboxColumns.Text;
dValue.DataType = Type.GetType("System.String");
dataTable.Columns.Add(dValue);
dataTable.Columns.Add(dMember);
conn.Close();
MessageBox.Show("Column Added");
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Edit: On second thought, I suspect it is far more complicated than what I initially wrote, and will now remove. Since this is an Access MDB, you need to add permanent tables and columns to the database using ActiveX data objects; I am reasonably certain you can not permanently add tables or columns to Access MDBs via OLEDB. I know there have been some posts on this subject recently in this forum, a search for those posts should show the way.
modified on Tuesday, July 29, 2008 9:15 AM
|
|
|
|
|
Hi pass. It didn't. I still don't get the Column created. I have changed the code as follows. I'm not sure if I am selecting the column.
private void btnAddColumn_Click(object sender, EventArgs e)
{
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = T:\Nasmeea\PSSZ.mdb";
conn.Open();
DataAdapter = new OleDbDataAdapter("Select * From [DivInfo]", conn);
DataColumn dValue = new DataColumn();
DataTable dataTable = new DataTable("[DivInfo]");
dValue.ColumnName = txtboxColumns.Text.ToString();
dValue.DataType = Type.GetType("System.String");
dataTable.Columns.Add(dValue);
dataTable.AcceptChanges();
conn.Close();
MessageBox.Show("Column Added");
}
Now, within the Database PSSZ.MDB i have an existing table called DivInfo. Am I connecting correctly to the database and dataTable in the above code? Sorry, should probably have also said that I have taken the code from a sample on the web but they don't mention any of the connection strings etc.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Please see my edits to my original post.
I apologize for my misdirection.
|
|
|
|
|
Hi,
These are my review points.
1. You don't have a variable for DataAdapter.
2. What is the purpose of the DataAdapater if your codes are not filling this.
3. You don't have a columnName and data Type for dMember Variable.
4. Opening and Closing of Connection are not necessary for DataAdapter. Data
Adapter will automatically do this for you.
Here are the correct codes.
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = T:\Nasmeea\PSSZ.mdb";
conn.Open();
DataAdapter da = new DataAdapter("Select field1, field2 From [DivInfo]", conn);
DataTable dataTable = new DataTable("System_Setting");
da.Fill(dataTable);
DataColumn dValue = new DataColumn();
DataColumn dMember = new DataColumn();
dValue.ColumnName = "dValue";
dValue.DataType = Type.GetType("System.String");
dMember.ColumnName = "dMember";
dMember.DataType = Type.GetType("System.String");
dataTable.Columns.Add(dValue);
dataTable.Columns.Add(dMember);
conn.Close();
MessageBox.Show("Column Count:" + dataTable.Columns.Count.ToString());
MessageBox.Show("Row Count:" + dataTable.Rows.Count.ToString());
Regards,
modified on Tuesday, July 29, 2008 9:26 AM
|
|
|
|
|
Hi AMrk. Thanks for the information. I have tried the changes above and it still doesn't work.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi,
I wondering what went wrong!
I've tried on my oracle database and it is working perfectly before posting my solution to your problem.
Here are my exact code which almost the same with your codes.
System.Data.OracleClient.OracleConnection conn = new OracleConnection();
conn.ConnectionString = "Data Source=testDB;User ID=Claims;Password=claim2be;";
OracleDataAdapter da = new OracleDataAdapter("Select Key,Value From System_Setting", conn);
DataTable dataTable = new DataTable("System_Setting");
da.Fill(dataTable);
DataColumn dValue = new DataColumn();
DataColumn dMember = new DataColumn();
dValue.ColumnName = "dValue";
dValue.DataType = Type.GetType("System.String");
dMember.ColumnName = "dMember";
dMember.DataType = Type.GetType("System.String");
dataTable.Columns.Add(dValue);
dataTable.Columns.Add(dMember);
The output of my codes for column count is 4 my columns are Key,Value,dMember and dValue.
Please be specific with regards of actual and expected output, errors and othere information which will help us to resolve your problem.
Thanks,
|
|
|
|
|
HI mate. I think it has to do with OLEDB. Apparently you can not create extra columns with it. When trying to create the Column, specifying dValue and dMember to have the same Column names it throws an error saying that it can not create as it already exist but when checking the Table the column doesn't exist. One can apparently not create a permanent column with OLEDB.
Thanks for the help and advice.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
How you are checking whether the columns are added or not? From your code there should be two columns in the dataTable before it goes of of scope. Also I could not see the use of dataadapter/connection, Is there any which is affecting the existing variable?
*jaans
|
|
|
|
|
This is the modified code I have now. I only connect to the DB on button click even. From the count at the bottom of the code it picks up the correct table etc but it for some reason doesn't add the new column. I currently have 29 columns in the DB with approximately 2000 rows of data. It returns all that showing that I am successfully connecting and it is reading the correct table.
private void btnAddColumn_Click(object sender, EventArgs e)
{
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = T:\Nasmeea\PSSZ.mdb";
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter("Select * From [DivInfo]", conn);
DataTable dataTable = new DataTable("DivInfo");
da.Fill(dataTable);
DataColumn dValue = new DataColumn();
dValue.ColumnName = txtboxColumns.Text.ToString();
dValue.DataType = Type.GetType("System.String");
dataTable.Columns.Add(dValue);
dataTable.AcceptChanges();
conn.Close();
MessageBox.Show("Column Count:" + dataTable.Columns.Count.ToString());
MessageBox.Show("Row Count: " + dataTable.Rows.Count.ToString());
}
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi,
Please add these codes after the da.Fill(dataTable);
MessageBox.Show("Column Count:" + dataTable.Columns.Count.ToString());
MessageBox.Show("Row Count: " + dataTable.Rows.Count.ToString());
You have 4 messagebox. 2 before adding the dynamic columns and another 2 after the adding.
Let us know what are the outputs of the messagebox
modified on Tuesday, July 29, 2008 9:53 AM
|
|
|
|
|
Hi Mark. Apparently I have to use ActiveX objects to create the Columns as OLEDB can not add the columns on the "fly" permanently. I will have to readup on this.
Thanks for the help and advice. The code is correct and should work on any other type of database except for Access Databases.
Once I have found a solution I will post again.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi MArk. I added the MessageBox stuff in after the da.Fill and it pops up with 28 columns. After the conn.Close() statement the count is 29 which menas that it is creating the Column but for some reason it is not saving the change which I find very strange. I have tried to see if I could find something on ADO to do this but everything I have come across does exactly the same thing. Nothing different and most of the code samples and articles refer to DATAGRID and not the DB itself.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
hello, hru? I want to know is it possible in winforms c# to add sqldatasource like control that gives all the options of select, insert, update, delete, stored procedures etc etc .... OR any other alternate solution to make my development simple.
thanks in advance.
|
|
|
|
|
Yes, Use the DataAdapter and Connection Control.
|
|
|
|
|
hello friends
I am using a control ( com component ) which is generally used to work in visual basics
so presently i am getting two files with my exe under debug folder
AxInterop.xyz.dll
and
Interop.xyz.dll
Now i want to deploy this application, previously i used to do this by adding the dll in the GAC folder but now i am unable to do this ..
Please help me to solve this issue
Thanks and regards
Krazy programmer
Happy Programming
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
I am actually surprised you were ever able to move those DLLs to the GAC folder. Anyways...
If you deploy the two Interop dlls to the same directory as the .NET application(s) where they are used, and ensure that the COM component from which they were derived is registered somewhere on the PC (the System folder or some folder where your company prefers to register COM components), you should be fine.
If you are using a .NET setup project for deployment, then you probably want to ensure that the 'File Installation Properties' Register property for the COM component is set to vsdrfCOMSelfReg (assuming it is a registered COM component). The Interop DLLs do not get registered; dropping them in the same folder as the application that uses them will be fine.
|
|
|
|
|
Hi gurus, I'm looking for a collection that combines the functionality of a list and dictionary. I basically want to be able to keep the order in which the items are added and at the same time do fast lookup? O(log n) as opposed to O(n), does this thing exist or do I have to write it myself?
Regards
|
|
|
|
|
If you can use a SortedDictionary, it's loopup is a O(log n) operation.
Otherwise you need to write it yourself. Just wrap a List and a Dictionary in a class, write an Add method that adds an item to both collections, and properties to get the values by index and by key.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|