|
Hi all, idont know where am i going wrong please help me.My idea is that, i am retrieving the deptnames from database into the dropdown list and afterthe selection of the deptname the respective details are to be displayed on the datagrid. The code is working till the dropdownlist.
code to get deptnames to the dropdownlist:
private void Page_Load(object sender, System.EventArgs e)
{
try
{
connectdb();
Cmd.CommandText = "Select distinct (Dept) from emp";
da.SelectCommand = Cmd;
da.Fill(ds,"Emp");
DropDownList1.Items.Clear();
foreach (DataRow dr in ds.Tables["emp"].Rows)
{
DropDownList1.Items.Add(dr["Dept"].ToString());
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Con.Close();
}
code to dispaly the details onto datagrid:
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
try
{
connectdb();
Cmd.CommandText = "Select * from emp Where Dept Like '" + DropDownList1.SelectedItem.Value.ToString() + "' order by Empno";
da.SelectCommand = Cmd;
da.Fill(ds,"Emp");
DataGrid1.DataSource = ds;
DataGrid1.DataMember = "Emp";
DataGrid1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Con.Close();
}
Note: The same code is working if i enter the deptname in a textbox and click the button to display details on to the datagid. But the code is not working if i select the option in the dropdownlist.Is the event Dropdownlist_SelectedIndexChanged relevent or any other events are there to select the dropdownlist.
pleasehelp me
thanks in advance
yamini
|
|
|
|
|
Hi,
By default AutoPostBack property for dropdown list is set to false, set the AutoPostBack property to true
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
Can anyone give me the exact difference between Virtual and Override? I am a bit confused...
Bikash Rai
|
|
|
|
|
Virtual indicates that any inherriting class may override the function and replace it with its own content. The keyword override indicates that I intend to replace a function out of a base class with my own.
So you can only use override when a member in the base class is declared as: virtual, abstract or override. (as stated in the override article on the MSDN)
The related articles from MSDN are:
virtual
override
|
|
|
|
|
Gerben Jongerius wrote: So you can only use override when a member in the base class is declared as: virtual, abstract or override.
Lets say that I have a base class A. A has one virtual function whose name is func. Now I create another class B which inherits from A. I override the function func using the override modifier. Lets say I create another class C which inherits from B. Now, if I have to override the function func of B in C then do I use override?
Thanks for helping.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
yep, you use override once again.
override states that it is overriding the function from the base class, and the overridden function still remains virtual, meaning that classes that derive from the class that overrode the func can still override it and do their own stuff...
Greetings,
Davy
|
|
|
|
|
Thanks a mil..
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
How can send file to server with webservice
|
|
|
|
|
What server? Windows, Samba, Linux, FTP, TFTP, Web, ..., ??? How does the webservice figure into this problem?
If you expect any help with this, you have to supply more detail in your question.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Windows server.
Send the file from computer A to computer B,this computer in different place.
|
|
|
|
|
A web service really isn't the best choice for this. And you're still very short on the details. A web service must be called from a client. It's not just running in the background all the time like a Windows service.
You have some problems with this.
First, where is the file comming from? (Remember those DETAILS you're not telling us about?) Is it comming from an upload from the client to a folder on the web service server? Is it being uploaded using a method of the web service?
Second, is the server that is going to receive this file from the web service part of a Windows domain? Are both the target server and the web service server in the same domain? Or are they seperate, usch as different domains or workgroups?
What type of target server are you sending this file to? Windows 2003 is fine, but what server type are you sending this file to? An FTP Server?, A Windows Share?, ..., ???
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I wrote a video jukebox program in C# last year. I initially used the AudioVideoPlayback namespace, but it's really buggy, so I used the WMP control instead. However, we used DX to read ID3 tags in the manager program. Now, a year later, the client has changed the contact person, and every machine he tries to install on gives him this error :
The type initializer for "Microsoft.DirectX.DirentInput.Manager" threw an exception.
in the constructor for the class that uses DX. The machines are all XP SP2, which means that DX is installed, although I'm not sure if managed DX gets installed by SP2, the installer won't run as it's there already.
The real worry is, it works fine on my dev machine, and works fine on his machine at home. I've tried with a couple of dll versions ( I have several installed ).
My constructor looks like this :
public JukeboxDXJoystickController()
{
foreach(DeviceInstance di in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
{
device = new Device(di.InstanceGuid);
}
if (device == null)
{
MessageBox.Show("Unable to find attached joystick");
return;
}
device.SetDataFormat(DeviceDataFormat.Joystick);
device.SetCooperativeLevel(null, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
device.Properties.AxisModeAbsolute = true;
deviceUpdated = new AutoResetEvent(false);
appShutDown = new ManualResetEvent(false);
device.SetEventNotification(deviceUpdated);
Thread threadLoop = new Thread(new ThreadStart(this.ThreadLoop));
threadLoop.Start();
device.Acquire();
}
I previously used joyGetPos, etc, but they proved to be unreliable in C#. We can still use them and the program runs fine. Any suggestions are most appreciated.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Chris!
I'm pretty sure that Managed DirectX is not installed out of the box, so I'd try installing it first.
Regards,
mav
|
|
|
|
|
I'm sure you're right, but as it's the latest version in SP2, trying to install over the top is not possible.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Good evening ( although it's night time in Sweden)
I'm trying to delete all my records in a single table with a DataAdapter. The code I use is this:
odbAdapter = new OleDbDataAdapter();<br />
odbAdapter.SelectCommand = new OleDbCommand("Select * from Bilder", odbConnection);<br />
OleDbCommandBuilder cb = new OleDbCommandBuilder(odbAdapter);<br />
<br />
odbConnection.Open();<br />
odbAdapter.Fill(ds, "Bilder");<br />
<br />
DataTable dt = ds.Tables["Bilder"];<br />
<br />
DataRow[] dr = dt.Select();<br />
<br />
foreach(DataRow item in dr)<br />
{<br />
item.Delete();<br />
}<br />
<br />
odbAdapter.DeleteCommand = cb.GetDeleteCommand();<br />
odbAdapter.Update(ds,"Bilder");<br />
However, I get an error message saying :
Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information
I'm guessing this has something to do with a primary key or something, judging by info gathered at other places. The primary key in the table is not automatically generated or anything. What the heck am i doing wrong here?
|
|
|
|
|
Why are you using a DataAdapter for this? If all you want to do is delete all the records in a table, why have the database waste the time retrieving them all and send them to you, just so you can tag them all for delete (one at a time, very time consuming!), then have the Adapter run a delete command on them (one at a time again!)?
Just tell the database to delete them all yourself!
string sql = "DELETE Bilder";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbCommand comm = new OleDbCommand(sql, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 21:55 Thursday 22nd December, 2005
|
|
|
|
|
Stefan R wrote: Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information
Since your SELECT command is returning all the columns of the Bilder table, this message means that your table doesn't have a Primary Key. DataAdapters will only work with tables that define a Primary Key.
This is because changes that are made you the DataSet are written back to the database one record at a time. The DataAdapter looks at each record in the DataSet and determines which SQL Command to execute against that record in order to properly update the database, wheather it be an INSERT, UPDATE, or DELETE command.
Now, if the DataAdapter is making changes to the tables in the DataSet one record at a time, how does it know how to tell the database which record to change? This is what the Primary KLey in each table is for. Without it, the DataAdapter has no consistant way of uniquely identifying every record in each tabel in the dataset.
For example, when you delete a record out of the DataSet, the DataAdapter executes a SQL DELETE command against that record. That command will look something like this:
DELETE FROM tableName WHERE PriKeyColumnName = DataSetPriKeyValue
This DELETE command is generated by the CommandBuilder object you created. It looks at the SELECT statement and the returned DataSet and uses the information in that set to generate the respective UPDATE, INSERT, and DELETE SQL statements, each with a WHERE clause that identifies which record in the database to execute the statement against.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know i can easily delete all records with "delete from biler" and i know the problem is not related to my SQL-statements or db schema. I'm just new to working with the DataSet. Since i want to learn how to work with the dataset i want to avoid using the method above. I want to be able to remove records one by one in the future...
The table has a primary key defined in my Access db, however it seems that the DataAdapter doesn't retrieve any meta data about primary keys and constraints from the table( as stated in msdn ). That's probably way the message says that i don't have a primary key. MSDN also states that i should specify which column is the key column somewhere in code and i have read something about MissingSchemaAction.AddWithKey ...
The problem is that i can't seem to get it right. How do i make the DataAdapter fetch information about the primary key? Or how do i tell the DataAdapter that a certain column in the fetched table is actually a primary key column? This is really bugging me out
-- modified at 4:59 Friday 23rd December, 2005
|
|
|
|
|
There's go to be something wrong with your table then. There's no problem with using a DataAdapter with an Access table.
If your table is correct, then you really don't have a need to specify which column is the PK. I've never run into the problem. This code works just fine:
[EDIT]Sorry, wrong language for the forum...[/EDIT]
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\TestBlank.mdb";
string sql = "SELECT * From MyTable";
OleDbDataAdapter da = new OleDbDataAdapter(sql, connString);
OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds, "MyTable");
foreach (DataRow row in ds.Tables("MyTable").Rows)
{
Debug.WriteLine("ID: " + row("TestID"));
row.Delete();
}
da.DeleteCommand = cb.GetDeleteCommand();
da.Update(ds, "MyTable");
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 10:25 Friday 23rd December, 2005
|
|
|
|
|
I tried changing primary key data type from "PM" to "Text" in the db and now it works just fine. I really did have a primary key though , and after reading that thing about "...OleDbDataAdapter not fetching primary key constraints..." on MSDN i really thought i was in trouble.
But as always, the problem lies in something small and unsignificant to the eye
Dave Kreskowiak wrote: [EDIT]Sorry, wrong language for the forum...[/EDIT]
I'm pretty fluent in VB syntax so i don't mind
Thanks a lot for the help!
|
|
|
|
|
Stefan R wrote: I'm pretty fluent in VB syntax so i don't mind
Yeah, I changed the code becauseif you're caught posting VB code in the C# Forum, ... well, let's just say it makes the movie "Desparado" look like a Sunday Brunch.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
if i create a webbrowser object, and there is a form (with name="something") on the page displayed, is there a way i can automatically submit it using c#?
thanks in advance,
sam kline
<a href="http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450">YES</a>
|
|
|
|
|
Hi, Does anyone know a good way to make reports in c#? not in Crystal Reports(Money issue) ..
i'm lookin for a simple report, maybe something thats like access reports.. ..
any idea will do ..
thanks in advance ,.. Yosi.
|
|
|
|
|
There is at least one free library that draws graphs, you could use that to create your own report, I guess. You'd have the data you need from your data source already.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|