|
shah123 wrote: OleDbDataAdapter adp=new OleDbDataAdapter(sql,database); adp = new OleDbDataAdapter(sql2,database);
you are using the same data adapter for box queries. Is this what you want to do?
You need to process the first data adapter before reusing it or use different data adapter, even better, refactor your code and call it as many times as you want, for example
FillComboBox(comboBox, sql)
{
DataSet ds = new DataSet();
try
{
database = new OleDbConnection(connectionString);
database.Open();
OleDbDataAdapter adp = new OleDbDataAdapter(sql, database);
adp.Fill(ds, "tableName");
foreach (DataRow dr in ds.Tables[0].Rows)
{
comboBox.Items.Add(dr[0].ToString());
}
}
catch (Exception x)
{
MessageBox.Show(x.Message);
}
}
Yusuf
|
|
|
|
|
Thanks Yusuf, But i have one different issue then just oledb exception...
I have two tables
Products=ProdId,ProdName,Price,Packing(Number as datatype)
Packing=packingId,PackingName (Text as datatype)
Now below code is in C# ..first check pls if "sql2" is correct query and then
when i execute an application i get an error "Expression Mismatch" on line:
adp.Fill(ds,"PackingName");
Thanks,
regards,
|
|
|
|
|
I got the solution of how to tackle and did it by doing SQL query again to be bit corrected..and now no exception...
private void Form1_Load(object sender, EventArgs e)
{
string sql ="SELECT distinct ProductName FROM Products";
string sql2 = "SELECT DISTINCT Packing.PackingName FROM Packing INNER JOIN Products ON Packing.PackingID=Products.Packing";
DataSet ds=new DataSet();
try
{
database = new OleDbConnection(connectionString);
database.Open();
}
catch (Exception x)
{
MessageBox.Show(x.Message);
}
OleDbDataAdapter adp = new OleDbDataAdapter(sql, database);
adp.Fill(ds, "ProductName");
adp = new OleDbDataAdapter(sql2, database);
adp.Fill(ds,"PackingName");
foreach (DataRow dr in ds.Tables[0].Rows)
{
comboBox3.Items.Add(dr[0].ToString()) ;
comboBox1.Items.Add(dr[1].ToString());
}
But now in combobox1 i get the same values as in combobox3?
I think so pb in foreach loop?
Any advise please...
|
|
|
|
|
Hi,
I have a problem with connecting Lotus Notes via OLE. The connector itself is working and I can generate an E-Mail. But I cannot access the property ConvertMIME.
I have played around a little bit and found out:
Type NotesSessionType = Type.GetTypeFromProgID("Notes.NotesSession");
object NotesSession = Activator.CreateInstance(NotesSessionType);
bool obj = (bool)NotesSessionType.InvokeMember("ConvertMIME", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty, null, NotesSession, null);
Works fine. But:
NotesSessionType.InvokeMember("ConvertMIME", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, NotesSession, new object[] {false});
Crashes with „TargetInvocationException“. HRESULT: 0x8000FFFF (E_UNEXPECTED). What I’m doing wrong?
|
|
|
|
|
Hi folks,
it seems to be a serious problem. I would like to thank all peoples who read the thread and thinking about it. I have solved this issue with a VB.DLL I wrote and call in C#. If you have another suggestion please post.
Regards
gremgiz
|
|
|
|
|
Hi
i'm looking for some tips and tricks about how to insert into relational data (Master/Detail) at the same time.
for example, user want to create new Customer, open Customer form to set it's values and insert some Orders for that Customer (which did not inserted into database yet) in Orders section, then save all together at the same time to database.
can anybody help me and has experience for this issue ?
thanks
|
|
|
|
|
A transaction could be used to wrap both insert statements into an atomic operation that would "behave" like a single statement.
I are troll
|
|
|
|
|
Thanks Eddy
I know this which run these operations under a single transaction, but my problem is that how to insert foreign key (from Customers) in to order record (because new customer has not been inserted yet, hence it does not a valid Primary key). i'm looking for some tips and tricks about this operation.
|
|
|
|
|
I think I don't understand exactly what you want/need. Would this help, or am I missing something in your question?
BEGIN TRANSACTION
INSERT INTO Customers (CustName) VALUES ('John') -- Id field is identity, and therefore not named in the fieldlist.
DECLARE @custId AS BIGINT
SELECT @custId = @@IDENTITY -- put new custId key into "@custId" var
INSERT INTO ORDER (OrderId, CustomerId) VALUES (1, @custId)
COMMIT TRANSACTION
I are troll
|
|
|
|
|
Thanks Eddy
I want almost this, but it's good for a one Order. how to do that for multiple Order at the same time ?
Note(Guide) : i want to iterate in Orders dataTable and insert each order into database.
|
|
|
|
|
It's good for an employee and an order. You can put as many SQL-statements in there as you want, SQL Server will keep treating them like an atomic operation
Put the start-transaction and the identity-retrieve statements in a string, and concatenate insert-statements for each order. When done, add the commit-transaction statement (or a rollback in case of error) and execute the string.
I are troll
|
|
|
|
|
Thanks again Eddy
It's good, but i have problem to pass dataTable to stored procedure withing a single transaction.
|
|
|
|
|
What you need to do is that after installing the customer. Fetch the customer id..
And then you can make an overloaded method to save an order where you provide the customerid..
And in that method code it in such a way that the customer id given differently is used and not on the table of orders. .
|
|
|
|
|
i am adding one custom property to textbox.when i click on this item i need to show one form (like popup window).and this form having one textbox and one button..after entering the text in textbox and click on ok button.i need to display the text in this custom property item..
please any one help me.
|
|
|
|
|
set ReadOnly(true) and Browsable(true)
|
|
|
|
|
Oh, man, please do not post duplicated question here. Nobody like this!
I Love KongFu~
|
|
|
|
|
Hi ,
i have a strange requirement...ie
i have an EXE in the website folder under IIS in server...and
i can access that exe from client thru url...
but i need to run that exe(which is in server) in client thru a dialog based application ie on buttonclick i need to run the exe in client...
what i did is on buttonclick event im trying to run cmd in the background in which im sending the parameters--> iexplore http://machinename/websitename/my.exe" when i run this im able to run the exe in client but IE browser is opening ....i do"nt want to display IE browser but the exe should run...(if this is not a better way pls let me know how can i run exe from server in client or i need to copy exe from server and paste in client and i run the exe without using server login credentials...)...
|
|
|
|
|
Using the following code you can download the exe in a local folder and then execute it:
System.Net.WebRequest request = System.Net.WebRequest.Create(remoteExe);
using (System.Net.WebResponse response = request.GetResponse())
{
using (System.IO.Stream stream = response.GetResponseStream())
{
byte[] content = new byte[response.ContentLength];
stream.Read(content, 0, content.Length);
System.IO.File.WriteAllBytes(localExe, content);
}
}
System.Diagnostics.Process.Start(localExe);
modified on Thursday, March 5, 2009 10:45 AM
|
|
|
|
|
thanks for this sample, it works.
But I have a problem. When I try to execute the copied .exe it doens't work.
File has same size..
What migth be wrong?
|
|
|
|
|
pradeep455 wrote: iexplore http://machinename/websitename/my.exe"
this will fire IE in deed.
You can not run an exe on the server from the client. What you can do it, download the exe to the client, then run it on the client.
Yusuf
|
|
|
|
|
How to connect microsoft access to c#.net? And how can i update tables in c#.net?
|
|
|
|
|
look into the system.data.oledb namespace
specifically the oledbconnection and oledbcommand classes
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
Did you even try to Google for an example? There's an example here[^], good luck
I are troll
|
|
|
|
|
Google ado.net
I Love KongFu~
|
|
|
|
|
Hi All
I have C# dll developed now I want to access it using JavaScript in ASP
I need to Register it as COM Server?
How can I do that
Thansk!
Develop2Program & Program2Develop
|
|
|
|