|
Very difficult to read with the corrupted formatting.
I think the following may be what you want
Select Count(*) from MyTable where Year = @P1 or Code = @P2
Use executescalar and box the return as an int and test that value
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks
Excuse me for bad to Read :
a simple instance is Here :
I want to Edit my Records , and Prevent the Duplicate Records e.g. :
----------------------------------
YearReg RegNo
1950 112
1950 102
1951 110
1950 114
-----------------------------------
For example in The All Records that Year is 1950 , RegNo shoulbe Unique and if Year=1951 , RegNo also unique and etc.
heres my code For EditButton Click :
...
string strQ = @"SELECT COUNT(RegNo) FROM tblRcvLet WHERE YearReg=@s1"
OleDbDataAdapter oda_Edited = new OleDbDataAdapter(strQ, ocn);
oda_Edited.SelectCommand.Parameters.Clear();
oda_Edited.SelectCommand.Parameters.AddWithValue(" @s1", txtYearReg.Text);
DataTable dt_Edited = new DataTable();
dt_Edited.Clear();
oda_Edited.Fill(dt_Edited);
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
else
{
OleDbCommand ocmd_Edited02 = new OleDbCommand();
ocmd_Edited02.CommandText = @"UPDATE ....
But I can Not Edit(Update) Records ...
Thanks a Lot
|
|
|
|
|
You can use datatable select option
string sql ="string strCondition = string.Format("Year = '{0}'", 2005);
DataRow[] row = dt.Select(strCondition);
|
|
|
|
|
I learn or relearn something every day - my excuse, I use collections these days.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Yes, it's possible. See this[^].
|
|
|
|
|
Absolutely yes.
You can keep the dll anywhere you want including the GAC where it could be shared across many applications.
|
|
|
|
|
HI,
Is there any way to find out user names who are currently accessing ACCESS database using C# window application.
Please suggest a solution.
Thanks
Bajrang
|
|
|
|
|
Generally, no. Access is a file-based desktop database. It doesn't have all of the facilities of a real SQL server.
|
|
|
|
|
thanks Dave for the reply.
But at least we can know how many users are accessing the DB.
Any clue.
Bajrang
|
|
|
|
|
Is this Access database sitting in a network share on a server?
|
|
|
|
|
yes some where in network
Bajrang
|
|
|
|
|
Then you can use DirectoryServices to get at it. You can find an example here[^].
|
|
|
|
|
You would need to trap the start and end events of the application part of the database, there is no system based logging of users in the database (it is a SINGLE user database after all).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: You would need to trap the start and end events of the application part of the database,
Presumably you mean in the C# application (versus the MS Access GUI app.)
|
|
|
|
|
jschell wrote: Presumably you mean in the C# application
God only knows, the poor bugger is using Access but as this is a C# forum, I presume you are correct.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes Mycroft Holmes, in C# Application only..
Bajrang
|
|
|
|
|
You can do it through ADO
This is VBA code, but it should give you the idea
Sub ReturnUserRoster()
Dim cnn As New ADODB.Connection
Dim rst As ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft " & _
"Office\Office\Samples\Northwind.mdb;"
Set rst = cnn.OpenSchema(adSchemaProviderSpecific _
, , JET_SCHEMA_USERROSTER)
Debug.Print rst.GetString
Set rst = Nothing
Set cnn = Nothing
End Sub
It's well known that if all the cat videos and porn disappeared from the internet there would be only one site left and it would be called whereareallthecatvideosandporn.com
|
|
|
|
|
I am hoping to get som advise from someone that has worked with audio programming in C#.
One of the thing I want to do is to play a section from a WAV file. E.g if the WAV file is 60 seconds long I want to be able to play e.g from 00:12 to 00:20 i.e 8 seconds. Any suggestions on how to do this? Any suggestions for good audio framework/libraries for C#?
Thanks
|
|
|
|
|
Why not search CodeProject, and examine the articles/code already here: example: searching on "c# audio .wav playback" => [^] ? Try varying the search terms. I predict you will find some resource here immediately useful to you; possibly, this: [^].
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
I am not positive on how to select the start/end position, but I know it is possible. I highly suggest using the NAudio library for this:
https://naudio.codeplex.com/[^]
NAudio is extremely robust and will provide you with everything you need. In the source code of the demo apps download, there are lots of examples on how to accomplish various tasks. I believe your answer is within one of those samples.
Hope that helps!
|
|
|
|
|
I remember I played around with playing MP3's a little bit with NAudio, here's a little bit of code that uses NAudio that may help you out...
IWavePlayer waveOutDevice;
WaveStream mainOutputStream;
WaveChannel32 volumeStream;
string fName = @"song.mp3";
private void Form1_Load(object sender, EventArgs e)
{
try
{
waveOutDevice = new WaveOut();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
}
}
private void btnPlay_Click(object sender, EventArgs e)
{
try
{
if (waveOutDevice.PlaybackState.ToString() == "Playing")
{
return;
}
mainOutputStream = CreateInputStream(fName);
waveOutDevice.Init(mainOutputStream);
waveOutDevice.PlaybackStopped += new EventHandler<StoppedEventArgs>(waveOutDevice_PlaybackStopped);
waveOutDevice.Play();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
}
}
private void waveOutDevice_PlaybackStopped(object sender, EventArgs e)
{
try
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
}
}
private void btnStop_Click(object sender, EventArgs e)
{
try
{
if (waveOutDevice != null)
{
waveOutDevice.Stop();
}
if (mainOutputStream != null)
{
volumeStream.Close();
mainOutputStream.Close();
}
if (timerPosition.Enabled)
{
timerPosition.Enabled = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
}
}
private WaveStream CreateInputStream(string fileName)
{
try
{
WaveChannel32 inputStream;
if (fileName.EndsWith(".mp3"))
{
WaveStream mp3Reader = new Mp3FileReader(fileName);
inputStream = new WaveChannel32(mp3Reader);
}
else
{
throw new InvalidOperationException("Unsupported extension");
}
volumeStream = inputStream;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
}
return volumeStream;
}
private void CloseWaveOut()
{
try
{
if (waveOutDevice != null)
{
waveOutDevice.Stop();
}
if (mainOutputStream != null)
{
volumeStream.Close();
volumeStream = null;
mainOutputStream.Close();
mainOutputStream = null;
}
if (waveOutDevice != null)
{
waveOutDevice.Dispose();
waveOutDevice = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
CloseWaveOut();
}
|
|
|
|
|
|
I have webservice and used memorycache to cache the lookups. My service is running on different machine. My client program accessing the that service is on other machine.
suppose my client calls the webservice and it gets data and add it to memory cache. Second time if client calls the webservice again, then does the cache will have the data or not (as my webservice and client are running on different machines)
|
|
|
|
|
The memory cache exists on the machine that the web service resides on.
|
|
|
|