|
I am working on a web application project. I am using c# as my programming language and an oracle 10g database.
I am in a situation where I need to read a large text file and Insert it in to an Oracle database.
I have used steamreader and the Oracle's odp.net and was able to successfully insert the text into a table.
Can one of you seasoned developres show me how to do the samething using Microsoft data provider(System.Data.Oracleclient name space)and if possible the streamreader. I appreciate your help.
|
|
|
|
|
I am working on an application that maintains an open connection to an sql database. I also have a timer that checks to see if the connection has closed and if so, it tries to re-opens the connection. This is working fine at the moment as my application and the database are running on the same computer. However this application will eventually run on a different computer to where the database will be. What I would like to know is if for some reason the connection from the computer running the application and the computer with the database were to become disconnected, would my application view this as the connection being closed?
|
|
|
|
|
Darkness84 wrote: I am working on an application that maintains an open connection to an sql database
First of all, I would like to know the conditions under which you need an open connection to the database (always) ?
I think you can open the connection just at the time of your query execution. what is the problem in this kind of scenario ?
Persisting database connections will load your database server. I dont think that this is desirable.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
I am using SqlDependency so that my application will respond immediately to changes in the database and thus i need the connection to be open.
|
|
|
|
|
Hi,
I dont know much about the SqlDependency, here[^] is an article on CP, which specifies (at the last) that the connection need not be open to recieve change event. Will this solve your problem ?
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Not sure, but I'll have a read. Thanks.
|
|
|
|
|
Hi All,
I am an Student and learning C#. my work is to write a class for calculating the number which is prime number and w ehave to call that method in a main program to display the output.
And i have to get the number from the user end using the Console.ReadLine().
No array declaration only using the for loop or the if else condition loop.
please help me in coding for calculating the Prime Number.
Awaiting your response ASAP.
Regards,
Chitra
|
|
|
|
|
You want us to do your homework for you? Seriously?
|
|
|
|
|
|
Thanks Guyz,
I have tried it as this but the problem is i have to put all the methods in a another class progam such as PrimeNumClass.cs and i have to call that in the main program to display the output.
here is my code:
<br />
namespace PrimeNumber<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
int n = 2;<br />
int totalPrimeNumbers = 0;<br />
int x;<br />
double sumOfPrimes = 0;<br />
<br />
while (n <= 100)<br />
{<br />
bool isPrime = true;<br />
<br />
for (x = 2; x < n; x++)<br />
{<br />
if ((n % x) == 0)<br />
{<br />
isPrime = false;<br />
break;<br />
}<br />
}<br />
<br />
if (isPrime == true)<br />
{<br />
Console.WriteLine(n + " is a prime Number.");<br />
<br />
sumOfPrimes = sumOfPrimes + n;<br />
totalPrimeNumbers++;<br />
}<br />
n++;<br />
}<br />
<br />
<br />
}<br />
}<br />
}<br />
Here everything is in Main Program itself. But i want it all in a seperate class Nmaed PrimeNumClass.cs and i have to call that class in the main Class to display the output.
please help me. itz very urgnet.
regards,
Chitra
|
|
|
|
|
chitra4sat wrote: Here everything is in Main Program itself. But i want it all in a seperate class Nmaed PrimeNumClass.cs and i have to call that class in the main Class to display the output.
Creating a new class is easy. Just right click on your project and click on Add then Class from the pop menu. Fill in the text box with the name of your of your class, in this case, PrimeNumClass.
The IDE will create a source file for you that looks like this:
using System;
using System.Collections.Generic;
using System.Text;
namespace PrimeNumber
{
class PrimeNumClass
{
}
}
Now, once you get to this point, you need to add a method to the class that contains your prime number algorithm. In this case, it would probably be best to make the method static. Also, make sure that it has public access so that it can be called from your Main function.
I'm going to leave it here and let you take over. If you have any problems, feel free to ask.
|
|
|
|
|
Hi Thanks,
I have created it as you said the PrimeNumClass as you have mentioned .
but what are all the things have to be inside that class and let me know it by code.
becoz i have the output in the main program and all the funcctions are carried out there. but i have been asked that in the main program there should not be anything but we have to create the object and w ehave to call that method to display the output of the prime number.
so please help me what to do ?
|
|
|
|
|
chitra4sat wrote: but what are all the things have to be inside that class and let me know it by code.
becoz i have the output in the main program and all the funcctions are carried out there. but i have been asked that in the main program there should not be anything but we have to create the object and w ehave to call that method to display the output of the prime number.
You need to add a method to your PrimeNumClass. For example, in your Program class, you have a method named Main. When you run your console application, the application invokes your Main method.
So add a method to your PrimeNumClass. You need to give your method a name, return type, and specify its access. In addition you need to decide if your method takes any arguments. For example, below is a class with no methods:
namespace ClassDemo
{
public class MyClass
{
}
}
Now, let's add a method to it that doesn't return anything and takes no arguments:
namespace ClassDemo
{
public class MyClass
{
public void SayHello()
{
Console.WriteLine("Hello!");
}
}
}
The class now has a method called SayHello. If I want to use this class, I can create an instance of it and invoke the SayHello method:
MyClass mc = new MyClass();
mc.SayHello();
Based on what I've shown you here, add a method to your PrimeNumClass. Then put the code you have in your Main method into this method.
|
|
|
|
|
I am trying create an Automation Add-in for Excel using .NET as per http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx[^], and http://www.codeproject.com/dotnet/excelnetauto.asp[^] using SharpDevelop V2.00. Having chosen to 'Register for Com Interop" in the project properties, a build produces the error "Cannot Register Assembly. Exception has been thrown by the target of an invocation. (MSB3217) Microsoft.Common.Targets."
As a complete newbie to C# and knowing nothing about .NET and COM, searching through forums and google on the error message, I still have no clues as to how to get rid of the error.
Can anyone point me in the right direction?
|
|
|
|
|
I'd like to change the way the value displayed in the grid.
So I create a class which derived from UITypeEditor and I have overriden the GetPaintValueSupported and PaintValue methods. Unfortunately there is a small rectangle display in the grid. Is there a way to remove this rectangle? So that I can draw whatever I want.
Thanks in advance....
|
|
|
|
|
Unfortunately this is impossible to get rid of this rectangle. It is painted internally AFTER your have painted inside the rectangle.
|
|
|
|
|
How is the function for block website that have been enter in text box and click add button it will appear in listbox. All this is in one form only.And another button for remove the web site have been add in listbox. The web site have been block will block by browser and this web site cant be acess. Please help me.Thanks A lot.
Below are the coding for the web site bloking form:
//List box
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
//TextBox
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
//Add button
private void Add_Click(object sender, EventArgs e)
{
}
//Remove
private void Remove_Click(object sender, EventArgs e)
{
}
Tq...
|
|
|
|
|
I writing an windows app in C# that receives data via serial port.
I have a thread dedicated to reading from the serial port and when
it has a full packet, it makes a call to the main form.
CallBackUpdate callBack = new CallBackUpdate(updateState);<br />
Invoke(callBack, new object[] { newPacket });<br />
So it passes the newPacket to a method called updateState.
Lets say this happens: (Although I don't think it will)
1.Receive one packet and is sent to main form for processing.
2.Receive another packet and send it to main form before packet from 1 is done processing.
Question/Concern
Will the main form process the first packet completely before it processes the second?
or
Do I have to add some blocking to the serial thread so that it doesn't send a packet for
processing when another is being processed.
|
|
|
|
|
dino2094 wrote: Invoke(callBack, new object[] { newPacket });
Careful here. This will block until the Form invokes the delegate and it completes. Your serial port thread won't be able to do anything else. Perhaps try BeginInvoke instead.
dino2094 wrote: Will the main form process the first packet completely before it processes the second?
Yes.
dino2094 wrote: Do I have to add some blocking to the serial thread so that it doesn't send a packet for
processing when another is being processed.
Well, you get that for free by using Invoke rather than BeginInvoke. But I'm betting you'd probably want to use BeginInvoke instead.
|
|
|
|
|
Program type: preferably windows service
Program Description
Part 1: polls sql table for recs with certain criteria (needs to check every minute or so)
Part 2: If part 1 finds recs that match, then part 2 needs to retrieve those records and do some work to them. (convert the records data into a xml document)
Part 3: The newly created xml document needs posted to a clients website (which gives a response of an error code or confirmation #)
Part 4: The original sql record needs updated with the confirmation and a flag signifying the task is done.
I am having problems figuring out how this should be done.. for instance if part 1 is checking every minute by using a timer if parts 2 - 4 haven't completed after part 1 has notified them the first time it might try to notify about the same records again
How would you keep everything organized
|
|
|
|
|
Mischievious wrote: I am having problems figuring out how this should be done.. for instance if part 1 is checking every minute by using a timer if parts 2 - 4 haven't completed after part 1 has notified them the first time it might try to notify about the same records again
Stop the timer after a match has been found. Restart it after completing part 4.
|
|
|
|
|
Thanks Leslie,
I guess that would be the logical thing to do. For some reason I was thinking that I needed to keep the polling part running while I was processing the records.
Thank you again for your help.
|
|
|
|
|
I am working on a project to encode videos by WMEncoder and having a problem.
If a video has no sound at all, then audio source shouldnt be created and added into group:
IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
SrcAud.SetInput("C:\\Inputfile.mpg", "", "");
But how to figure out if a video has sound or not?
The other question is how to cut thumbnail from a video by WMEncoder or WMFormat? I didnt see any samples.
Thanks!
|
|
|
|
|
I need to store configuration data in a single file and allow several projects to use this one file. For example:
<projects>
<project_one>
<authorname>Some name</authorname>
<projectname>some name</projectname>
<fullpath>D:\My Projects\Projectname1</fullpath>
<date>Date</date>
<param_one>some parameter</param_one>
</project_one>
<project_two>
<authorname>Some name</authorname>
<projectname>some name</projectname>
<fullpath>D:\My Projects\Projectname2</fullpath>
<date>Date</date>
<param_one>some parameter</param_one>
</project_two>
</projects>
I am confused about which class to use XmlTextReader/XmlTextWriter or XmlDocument? I simply need to append new project nodes, delete old ones, and retreive the data when necessary.
Thanks,
Mark
|
|
|
|
|
I think all your requierments can be fullfiled using XmlDocument Class[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|