|
thank you,
Just what i needed.
Russell
|
|
|
|
|
Greeting,
I made a solution with some projects.
Every project has it's own namespace.(ie,ns1,ns2,...)
When I want to use a namespace(ex in ns2 i want to use ns1) with this instruction :
using ns1;
at compile or build time this error occurred :
he type or namespace name 'ns1' could not be found (are you missing a using directive or an assembly reference?)
What I should to do to solve this problem?
Regards
|
|
|
|
|
have you referenced the project that contains a namespace from the one using it?
russell
|
|
|
|
|
I have a windows application of which I want to validate a survey data that was captured using another software and stored in an MS SQL server 2000 database table.
eg. I have three columns , Sex, Age, Marital status
if a person is less than 20 years and is reported to be married,
I have to fire the message that is the person is too young to be married. I was able to do that in VB 6.0:
This is the code snippet that was used in vb 6.0, I had a richtextbox object where I placed all the error messages.
-------------------
Dim adoTest As New ADODB.Connection
Dim rstTest As New ADODB.Recordset
Dim adoSearch As ADODB.Recordset
Dim census, i As Integer
Private Sub cmdTest_Click()
cd.ShowSave
rtb.SaveFile cd.FileName
End Sub
Private Sub Form_Load()
adoTest.CursorLocation = adUseClient
adoTest.Provider = "MSDASQL.1"
adoTest.ConnectionString = "Password=sa;Persist Security Info=True;User ID=sa;Data Source=LSA2006;Initial Catalog=LSA2006"
adoTest.Open
If adoTest.State = adStateOpen Then
MsgBox "Connexion with the server established", vbInformation, "Testing"
Else
MsgBox "Connexion Failed !", vbInformation, "Testing"
End If
rstTest.Open "select * from table2", adoTest, adOpenDynamic, adLockOptimistic
rtb.Text = ""
While Not rstTest.EOF
If rstTest!married = 1 And rstTest!age <= 15 Then
If rtb.Text = "" Then
rtb.Text = rstTest!id
Else
rtb.Text = rtb.Text & vbNewLine & rstTest!id & " Too young to get married"
End If
End If
If rstTest!age <= 20 And rstTest!education >= 3 Then
If rtb.Text = "" Then
rtb.Text = rstTest!id
Else
rtb.Text = rtb.Text & vbNewLine & rstTest!id & " Age not consistent with education"
End If
End If
rstTest.MoveNext
Wend
End Sub
-------------
Can anybody help me how to do this in C#. I have to do data validation quickly
Thank you
phokojoe
|
|
|
|
|
which bit are you haveing problems with?
I assume the problem is going to be with getting data from the db and getting your hands on the data.
Create a connection
Create a command containing your select command
assign the connection to the command
call executereader() on the command
datareader dr = myCommand.ExecuteReader()
while (dr.Read())
{
do stuff with dr fields
}
HTH
Russ
|
|
|
|
|
Yep!
Thanks a lot. It worked but to a certain level. I maneged to retrive just 1 record/column before I intoroduce the if statement. I have about 127 records at present, but when I introcude the if statement to compare the values and then display them in the richtextbox, I get the message on the if statement
"An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format."
this is the code
try
{
string str = "select * FROM table1";
con = new SqlConnection(_connect);
cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = str;
// Open the Connection
con.Open();
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (dr.Read())
{
if (System.Convert.ToInt32(dr[10]) < 20)
{
rtb.Text = dr[7].ToString();
}
}
}
catch(SqlException ex)
{
MessageBox.Show(ex.Message);
}
finally
{
// Close the Connection object
con.Close();
}
I am comparing column 10 with the age of the person that is 20 and then display the id of that particular record in textbox which is in column 7.
Can you please point where I am doing the wrong thing
Cheers!
phokojoe
|
|
|
|
|
sounds like it might be a rich text box problem to me. I only tried to use them once and found them too tricky for what i needed.
add a multiline textbox to your form and try putting the data in that just to check that all the logic is working.
Russ
|
|
|
|
|
Yep!
Thank you for responding. You are great. Actually I have already found where the problem was. I passed the array refence not the actual column name. I changed the dr[0] to dr["columnname"] and it poped up every row that meets the if statement conditon. And in the System.Convert.ToInt32 i changed that to ToInt16 and the condition wokrs fine. However I will aging write if I have a problem because I have to test for many columns against others.
Once agin
Thank you.
phokojoe
|
|
|
|
|
hi everyone!
I have a problem relating to Windows Services and FileSystemWatcherClass of .NET using c#.
I developed a windows service to monitor a specific folder on a server for changes and maintains its updated back up in another folder.
FileSystemWatcherClass is inherited to monitor and create mirror of a folder. It is available at http://www.codeproject.com/cs/files/directorymirror.asp?msg=1801877.
However, I found a limitation of this application. When copying large data (10 – 15 MB) it misses many events and only copies about half of the data. (This problem is also referred in the comments of the above article).
Possible cause of the problem:
When you copy or drop large amounts of data somewhere it can take several seconds for the system to write the data to the disk. The system cannot send feedback about the status of the operation (completed, failed, queued, etc) while it is performing it or while it is queued, and during this time other requests to the file system are queued by the system. This is what I think is the source of the problem: The FileSystemWatcher has no patience and throws an exception if it doesn’t get an IMMEDIATE response from the file system. So any big operation that takes a bit of time will end up throwing an exception and often but not always, cause the operation to abort. This class seems to be completely ignorant of how the windows file system works.
I found a solution to that on msdn, that says increase the INTERNALBUFFERSIZE. The Windows operating system notifies your component of file changes in a buffer created by the FileSystemWatcher. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification.
This solution resolved the problem somehow. I increased buffer to 64KB (default is 8192 bytes). This successfully copied data up to 35MB without missing a single file and suffices to my needs.
The problem is, when I integrated this into a Windows Service, it all failed to copy even 3 – 4 MB of Data. I have searching a lot but haven’t found the right solution yet.
I would be grateful if somebody could help me out with that. Thanks a lot for your patience of reading a long mail.
regards,
Fayyaz Khan Lodhi
fayyaz.lodhi@confiz.com
|
|
|
|
|
hi,
I have file1.xml (with more no.of tags, no repetition), and i need to search/extract the value for the given 'tag' ,
I use c# for coding,,, can i use dataset/xsd concept and readxml method.
And in some cases after retrieving the searched value i have to modify and save it back
(the task is to work on edi-documents)
Could u anybody please help me to solve this
|
|
|
|
|
Hi Plz use the below code for loading the file
doc.Load("E:\\C#\\ongoing project\\Chapter 21\\BellRingers.xml");
place your editing code here such as attribute editing value retrieving for example
private string getTowerName(XmlTextReader reader)
{
if (!reader.Name.Equals("tower"))
{
throw new Exception("Wrong type of data - expected a bell tower");
}
reader.MoveToAttribute(0); // Should be the tower name
return reader.Value;
}
and the below will then save the file
XmlTextWriter tr = new XmlTextWriter("E:\\C#\\ongoing project\\Chapter 21\\anewBellRingers.xml", null);
tr.Formatting = Formatting.Indented;
doc.WriteContentTo(tr);
tr.Close();
SAS
|
|
|
|
|
XmlDocument will help you do the job.
SkyWalker
|
|
|
|
|
Hi All i made an application ca someone please help me in making exe file of that
SAS
|
|
|
|
|
just build your project (or press F6) and you will see under bin/debug folder executable file
|
|
|
|
|
if i copy the exe from the debug folder in sme other system wil it work
SAS
|
|
|
|
|
if your project doesnt require any other file(like dll, txt file, etc) and if copied computer has .net framework(releated to your project) probably it will work. but i advice you make setup project of it
|
|
|
|
|
How To make a setup project if i make setup project then if installed in some other pc will it require framework 2.0 and if it have some additional dlls and classes plz explain thanx & regards
SAS
|
|
|
|
|
1- if you make a setup project or not, other pc will require framework when you start the program it hasnt your program wont run!
if you want to make a setup project follow the related link
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vbtskCreatingOrAddingSetupProject.asp
while you making setup project you can add you additional files. Also if other pc doesnt have framework it will you give a warning (there is no framework before installion) and give a link to microsoft framework download side, you can connect this side, or you can add framework to your setup project. (If you have framework installation file) if you have not, download it from microsoft. i hope that good for you
|
|
|
|
|
Under the debug folder you will also find the dll files of your dependencies and projects in your solution. All those files need to be on the target machine that you want to run your program from.
If you want to create a single exe that does the actual installation of the program (i.e. copy all the needed dll files onto the target machine you need to create a deployment project if you are using Visual Studio, otherwise you will need to get an external installer program which will package it all into a single exe file.)
If you are developing on the .Net framework you need to make sure that the target machine has the correct version of the framework installed.
He who laughs last is a bit on the slow side
|
|
|
|
|
What about csc yourcs.cs in the simplest case?
Type csc /? from your command line and see a lot more!
SkyWalker
|
|
|
|
|
I should point out, if you have made an application, you must have compiled the app, in order for it to run. This means you have already created the exe.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
It's not in debug it's in release folder... at least in express ed.
|
|
|
|
|
debug or release folder is depending on debugging options.
on visual studio debug is default
|
|
|
|
|
I have the following block of code
if( (nDecisionDate.CompareTo(timePickFrom.Value) >= 0) &&
(nDecisionDate.CompareTo(timePickTo.Value) <= 0)
)
{
//processing here
}
nDecisionDate is a DateTime type while timePickFrom is of type System.Windows.Forms.DateTimePicker. The code compiles and runs but it misses to go inside the block whenever nDecisionDate is equal to the beginning of the inclusive dates (i.e. the = in >=). What is the best way to compare a DateTime type to a DateTimePicker from a calendar tool?
it might be worth noting that nDecisionDate is a DateTime type that was cast from a string class which was from a sql resultset which is of type DateTime.
Thank you in advance.
|
|
|
|
|
You can subtract a DateTime from another and get a timespan. Also, you may find that this fails because the days are equal, but the times are not as you'd hoped.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|