|
You have to close the data reader after you have read all the data you need from it. In your code you would have to do that after the call to DataBind.
When you are moving data through several layers, you should consider to read the data into a DataSet, or a list of objects.
If you create a title class that has the properties you need in the combo box, you can use an ArrayList of such objects as a data source:
Class Title {
private int id;
private string name;
public Title(int id, string name) {
this.id = id;
this.name = name;
}
public int TitleID_PK { get { return this.id; } }
public string TitleName { get { return this.name; } }
}
You create the ArrayList by reading through the data reader:
ArrayList list = new ArrayList();
while (reader.Read()) {
list.Add(new Title(reader.GetInt32("TitleID_PK"), reader.GetString("TitleName")));
}
reader.Close();
---
b { font-weight: normal; }
|
|
|
|
|
How to create new column to display at datagrid??
DataSet ds = new DataSet();
DataTable t = new DataTable();
ds.Tables.Add(t);
DataColumn cNo = new DataColumn("No", Type.GetType ("System.Int32"),"");
cNo.AutoIncrement = true;
cNo.AutoIncrementSeed = 1;
cNo.AutoIncrementStep = 1;
t.Columns.Add(cNo);
those is wat i hav write, but stil can display the new column??
angela
|
|
|
|
|
after u add new column try to refresh ur table or close ur SqlConnection and open again
|
|
|
|
|
just wonder isn't my coding is put before
myConnection.Open();
da.Fill(ds);
myConnection.Close();
or after tat statement??
wat d coding for refresh function??
angela
|
|
|
|
|
i think u r adding datatable in dataset before adding column to datatable.
so try to add data table after adding datacolumn to datatable.
rahul
|
|
|
|
|
DataSet ds = new DataSet();
DataTable t = new DataTable();
ds.Tables.Add(t);
DataColumn cNo = new DataColumn("No", Type.GetType ("System.Int32"),"");
cNo.AutoIncrement = true;
cNo.AutoIncrementSeed = 1;
cNo.AutoIncrementStep = 1;
t.Columns.Add(cNo);
//1. close ur sqlconnection
//2. load ur data from ur table (select commad example: select * from urtable(when u give select * command then u can view ur new column...))
//3. open ur connection string
|
|
|
|
|
then d i need to add a column in my datagrid for this new autoincrement column. how i bind all of this to my datagrid?
angela
|
|
|
|
|
Hello!
I am making windows application. Design of that application need to be a little caracteristic. I don't wont to allow my users to change XP theme for my application.I have some stylesheat.dll for different themes. I don't know how to include that .dll files into my project because that is not type of .com files. Project is using default theme that is chosen into Display Properties -Appearence - Color scheme (Default Blue, silver, olive green).
I am working with C#. Plese, if you now how can I do that... write to me...
I am not shure is that even posible.
My e-mail is: snjezana@mpa.co.yu
Thank you,
Snowwhite
Snowwhite
|
|
|
|
|
How can the user change the XP theme of ur application,
The theme depends on the Operating System
if i have created an application on XP the application will have XP look only when it is run on that machine
but if i run the same application on 2000 the application will have 2000 theme and the color or the looks will be of 2000.
This is want i know.
if there is any way in which the applications Theme can be set constant for all the O.S.
Please write back.
Regards,
Pramod
|
|
|
|
|
I have made a program to play video file in directx (directx.AudioVideoplayback)! It worked well ! But I couldn't find the way to handle the video.owner !
when I did set the video.Owner = (name of my panel); I wanted to set video to full screen mode by double click on the video (in bool property video.FullScreen).
I tried to add Double Click EventHandler to my panel or video.Owner but It didn't work !
How can I do this ? Any ideas ... ?
-- modified at 0:24 Monday 6th March, 2006
|
|
|
|
|
????????????????????????????????????????????????????????????????????
-- modified at 9:29 Monday 6th March, 2006
|
|
|
|
|
I want to upload an image in my asp page but before uploading a want to check if the size of that image is: height = 80 and widht = 100.
Please look into this.
Deepak Anish
Computer Programmer
Maxumise Fiji Ltd
Suva, Fiji
|
|
|
|
|
deepak1 wrote: but before uploading
I don't think that you coudl do that in Javascript... meaning: I don't think you could do that at all.
On the other hand, once recieved on the server side you could check the pic before saving it into the database (and write a little confirmation / error message).
To test on the server side:
Bitmap bmp = new Bitmap(new MemoryStream(buffer));
if(bmp.Width > 100 || bmp.Height > 100)
....
|
|
|
|
|
After much thinking you could submit the data not through an FileUploadInput but through an ActiveX / JavaApplet, in which case you could do all the test you like....
|
|
|
|
|
Hello,
I am trying to execute the following code from a background worker's DoWork Event Handler and getting the error :Cross Thread Operation etc..etc... Can you kindly show me some ways to do this work. The following code does Extract Text from a MS word document file.
string textData ;
try
{
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
object file = fileName;
Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
textData = (data.GetData(DataFormats.Text)).ToString().Trim();
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);
}
catch (Exception error)
{
MessageBox.Show("Error Extracting Resume Text : " + error.Message);
}
-- modified at 16:24 Sunday 5th March, 2006
|
|
|
|
|
My guess is that the code that you're running happens to raise an exception and hit the line that displays a MessageBox. That operation is not allowed on a background thread so that's probably where it yells at you.
Try commenting out the "MessageBox.Show.." line and see if you still get that error.
Have you verified that yet?!
----
www.muzikstor.com
|
|
|
|
|
Hi,
Thanks for the reply. Actually I did not have problem showing Message Box in background worker thread. The error showing because it is acessing MS word file, openning it, selecting the text, copying the text and then a string is getting value of the selected copied text. And this selecting the text is being prohibited by background worker. OR can you show me some other way to extract TEXT from MS Word ? Even if I find a free command line MS word to text converter, I will be happy. I will use Diagnostics.Process in that case/
Thanks
|
|
|
|
|
Well, using COM Interops can be tricky. Whenever you work with COM automation you have to be mindful of the threading model of your application. Have you tried running your code in the main thread (not in the background worker thread)?
If so, and it works.. try creating the secondary thread manually instead of using the BackgroundWorker object. That may help.
Other than that, I'm running out of good ideas :p
----
www.muzikstor.com
|
|
|
|
|
Hi,
Thanks for your reply. Yes, This code is working excellent without Background Worker ( I mean, within Main Thread ). So, I will try using manual thread. I thought Background worker and manually created Thread are exactly same thing.
|
|
|
|
|
They are similar but as far as I know, the Background Worker thread object implements some extra functionality to properly marshal the calls between the threads. The funny thing is that it's supposed to fix just the type of problem you were experiencing. I'm surpized..
As I said earlier, I think you need to delve deeper into the details of the COM+ threading model and interacting with it from the a .NET mannaged thread.
----
www.muzikstor.com
|
|
|
|
|
Hi..
I want to creat my own smiley (draw it myself)
I have created a circle with the
System.Drawing.Graphics gf;
//Here i make the circle
gf.DrawEllipse(new Pen(Color.Black), 85, 50, 30, 30);
//Here I added 2 smaller cirles to be the eyes
gf.DrawEllipse(new Pen(Color.Black), 94, 59, 3, 3);
gf.DrawEllipse(new Pen(Color.Black), 104, 59, 3, 3);
but then my problem is to make the happy/sad mouth
it should be as simple as the good old smiley " or
I have tried by using the
gf.DrawCurve(-I had addes some values here-);
But I could not get it to work
Can anyone help me haw to draw this?
Thanks
QzRz
|
|
|
|
|
Try something like:
gf.DrawArc(new Pen(Color.Red), 90, 55, 20, 20, 45, 90);
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for the fast reply
It works just fine, thanks
|
|
|
|
|
Hello,
I am trying to create an e-mail application. I have created a simple mail application in win forms. The user will put in the fields and click the send button.
I am not really sure how an e-mail application works. But if send an e-mail to my e-mail account i.e. steve1_rm@hotmail.com. I send the e-mail. However, I never receive the e-mail that I send using this mail application. The application works ok, and there are no run-time errors. Is there something I need to do, to be able to send this to my hotmail, yahoo, or gmail e-mail accounts.
The code I have used is below. This has been written in C# Visual Studio 2005.
Thanks in advance
<br />
using System.Web.Mail;<br />
<br />
private void btnSend_Click(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
MailMessage aMessage = new MailMessage();<br />
aMessage.From = txtFrom.Text;<br />
aMessage.To = txtTo.Text;<br />
aMessage.Cc = txtCC.Text;<br />
aMessage.Bcc = txtBCC.Text;<br />
aMessage.Subject = txtSubject.Text;<br />
aMessage.Body = txtMessage.Text;<br />
<br />
if (txtAttachment.Text.Length > 0)<br />
{<br />
aMessage.Attachments.Add(new MailAttachment(txtAttachment.Text, MailEncoding.Base64));<br />
}<br />
<br />
SmtpMail.Send(aMessage);<br />
<br />
MessageBox.Show("Message sent to " + txtTo.Text, "E-mail Program", MessageBoxButtons.OK, MessageBoxIcon.Information);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message.ToString());<br />
}<br />
|
|
|
|
|
You need an SMTP server. If you don't have one installed on the computer you are running, specify the address of the SMTP server to use in the SmtpServer property in the SmtpMail class.
---
b { font-weight: normal; }
|
|
|
|