|
Looks like all the objects are created as required; the first suspect I see, is the irrelevant singleton that 'guards' the connection. You might wanna try opening and closing the connection without doing anything else, to 'test' that part of the structure.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Debug and locate an object that is null. That null value is causing this error.
|
|
|
|
|
Can anyone suggest me how to develop a chatting application in C#?
|
|
|
|
|
You're going to have to be more specific than that!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I mean what should I be knowing to make it possible. I am new to the developing field. I need your suggestions.
|
|
|
|
|
You need to use these concepts
1.WCF Web Service with the client polling the service (simple-basic scenario - easy to implement, not very efficient)
2.WCF Duplex Web Service with the server updating clients when needed (a bit more complicated)
3.TCP Socket-based solution, hardest to implement but permits much better control. There is a very good example in Matthew McDonald's book "Pro Silverlight 3"
http://stackoverflow.com/questions/4716279/need-concept-regarding-windows-based-chat-application[^]
|
|
|
|
|
|
The client, or the server? What protocol? Does it need to interface with MSN? Or with Google Talk?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi All, I am trying to replace the text of various radiobuttons with data stored in a database. Since this is not a Windows Form application, I had to use the using keyword to create a datatable and because of that the datatable is not visible outside of the using code block. Please take a look at my code below.
string Con = ConfigurationManager.ConnectionStrings["myCon"].ConnectionString;
using (OleDbConnection OleCon = new OleDbConnection())
{
OleCon.ConnectionString = Con;
OleCon.Open();
using (OleDbDataAdapter a = new OleDbDataAdapter("SELECT * FROM CustomerTable", OleCon))
{
DataTable myDataTable = new DataTable();
a.Fill(myDataTable);
}
}
int i =1;
while(i<myDataTable.Count)
{
i++;
}
I get the error message saying that myDataTable does not exist in the current context. How do I make it visible to code outside of the using block? Thanks in advance for your reply.
|
|
|
|
|
Declare it before the using statement.
|
|
|
|
|
You decalre it outside of the using block.
ASPnoob wrote: Since this is not a Windows Form application, I had to use the using keyword to
create a datatable
Uhhh, whether or not this is a Windows Forms app has nothing to do with using a using block. It's a stucture that can be used in any type of application and if you can use it or not depends on the object that your specifying in the using statement. That object must implement the IDisposable interface.
|
|
|
|
|
Hi All,
I am trying to add an element from List1 to List2 if it is not already in List2. The following is what I have and I'm getting the error message List1 is a variable but is used like a method.
List<RadioButton> List2 = new List<RadioButton>();
List<RadioButton> List1 = new List<RadioButton>();
List1.Add(0,null);
List1.Add(1,RadioButton1);
List1.Add(2,RadioButton2);
List1.Add(3,RadioButton3);
List1.Add(4,RadioButton4);
int listIndex = RandNum.Next(1, 4);
int i=1;
while(i<List1.Count)
{
if (!List2.Contains(List1(listIndex )))
{
List2.Add(List1(listIndex ));
i++;
}
}
Please explain what I am doing wrong. Thanks in advance.
modified 20-Oct-12 8:59am.
|
|
|
|
|
Your calls to the Add() method are trying to pass two parameters but Add() only takes one, a reference to a radio button. Also, in the lines at the end starting with
if (!List2.Contains(List1(listIndex )))
your syntax is incorrect for an indexing operation, it needs square brackets not parentheses, thus:
if (!List2.Contains(List1[listIndex]))
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi, thanks for replying. I guess the Insert method is what I need if I wanted to add value to a list at a specific index.
|
|
|
|
|
Sounds about right.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I have navigate a website that have a script to print the page on login. when i close the page via code before print dialog shown , the webbrowser shows the print dialog even the page is already closed.
the script use : Document.print()
how to kill thread comes from the page on closing.
i need to close the page and close the print dialog.
please help
|
|
|
|
|
You can't. Once it's presented to the user there is no way for your code to close the print dialog.
|
|
|
|
|
I make the windows form on which on a single button click performs like this
private void button1_Click(object sender, EventArgs e)
{
Excel.Application exapp=null;
Excel.Workbook exbook=null;
Excel.Worksheet exsheet = null;
object misvalue = System.Reflection.Missing.Value;
exapp = new Excel.Application();
exapp.SheetsInNewWorkbook = 1;
exbook = exapp.Workbooks.Add(misvalue);
exsheet = (Excel.Worksheet)exbook.Worksheets.get_Item(1);
exsheet.Cells[1, 1] = "First Name";
exsheet.Cells[1, 2] = "Last Name";
exsheet.Cells[1, 3] = "Address1";
exsheet.Cells[1, 4] = "Address2";
exsheet.Cells[1, 5] = "City";
exsheet.Cells[1, 6] = "PinCode";
exsheet.Cells[1, 7] = "Phone Number";
exsheet.Cells[2, 1] = textBox1.Text.ToString();
exsheet.Cells[2, 2] = textBox2.Text.ToString();
exsheet.Cells[2, 3] = textBox3.Text.ToString();
exsheet.Cells[2, 4] = textBox4.Text.ToString();
exsheet.Cells[2, 5] = textBox5.Text.ToString();
exsheet.Cells[2, 6] = textBox6.Text.ToString();
exsheet.Cells[2, 7] = textBox7.Text.ToString();
exbook.SaveAs("rep.xls", Excel.XlFileFormat.xlWorkbookNormal, misvalue, misvalue, misvalue, misvalue, Excel.XlSaveAsAccessMode.xlExclusive, misvalue, misvalue, misvalue, misvalue, misvalue);
exapp.Quit();
releaseObject(exapp);
releaseObject(exbook);
releaseObject(exsheet);
}
but this thing imports data from windows in only one sheet
but i want to make a new sheet one each button click in excel
can anybody help me in it??????
Thanks in advance
|
|
|
|
|
I guess you need to create your workbook outside of this method. Then, when this method gets called it should add a new sheet to the workbook, fill that sheet with the data and save the workbook. You can then close the workbook at the end of the program.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
Excel.Application exapp=null;
Excel.Workbook exbook=null;
Excel.Worksheet exsheet = null;
object misvalue =System.Reflection.Missing.Value;
string fname = Application.StartupPath + "rep.xls";
exapp = new Excel.Application();
if (!File.Exists(fileToOpen))
{
exbook = (Excel._Workbook)(exapp.Workbooks.Open
(fileToOpen,0, true, 5, _value,_value, false,Excel.XlPlatform.xlWindows, _value,false, true,_value, _value,_value, _value));
}
else
{
exapp.SheetsInNewWorkbook = 1;
}
exbook = exapp.Workbooks.Add(misvalue);
exsheet = (Excel.Worksheet)
exbook.Worksheets.get_Item(exbook.Sheets.Count);
exsheet.Cells[1, 1] = "First Name";
exsheet.Cells[1, 2] = "Last Name";
exsheet.Cells[1, 3] = "Address1";
exsheet.Cells[1, 4] = "Address2";
exsheet.Cells[1, 5] = "City";
exsheet.Cells[1, 6] = "PinCode";
exsheet.Cells[1, 7] = "Phone Number";
exsheet.Cells[2, 1] = textBox1.Text.ToString();
exsheet.Cells[2, 2] = textBox2.Text.ToString();
exsheet.Cells[2, 3] = textBox3.Text.ToString();
exsheet.Cells[2, 4] = textBox4.Text.ToString();
exsheet.Cells[2, 5] = textBox5.Text.ToString();
exsheet.Cells[2, 6] = textBox6.Text.ToString();
exsheet.Cells[2, 7] = textBox7.Text.ToString();
if (!File.Exists(fileToOpen))
{
exbook.SaveAs(fileToOpen,Excel.XlFileFormat.xlWorkbookNormal, misvalue, misvalue, misvalue, misvalue, Excel.XlSaveAsAccessMode.xlExclusive, misvalue, misvalue, misvalue, misvalue, misvalue);
}
else
{
exbook.Save();
}
exapp.Quit();
releaseObject(exapp);
releaseObject(exbook);
releaseObject(exsheet);
}
|
|
|
|
|
thnks zaher but it doesnt work.....
|
|
|
|
|
Hi All,
I am access my computer window. when i click on my computer icon than open my computer window but when again click on my computer icon than same window open .My actual problem is , i want to not open same my computer window click on My computer Icon. same window means - first open My computer window content is C: , D: , E: Drive and again open second window content is C: , D: , E: Drive (both my computer window views are same) . I Want to do not open same view of My computer window.
Thanks
Aniruddha
|
|
|
|
|
1) What does this have to do with C#?
2) What do you expect to happen? If you think of the "My Computer" icon as a "door" into the "My Computer" "room", then why would you expect that the first time you open the door, it is "My Bedroom" and the second time it is "My Kitchen"?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Then don't click on it a second time. Why do you believe something different should happen?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
This has absolutely nothing to do with C# or programming in general.
But, what you describe is expected behavior and you can't modify it.
|
|
|
|
|