|
One post is enough in BTW why are you creating the new thread for the same.
Regards,
Satips.
|
|
|
|
|
actually i m new to dot net
i m using oledb connection
and my query is
"select * from tableabc where name = ? and id = ?"
i dont know how to map these parameters to my command object can any body tell me please
thanks
hello
hello
|
|
|
|
|
Why are you creating the new thread for the same question.
pls correct it in the prevoius post itself.
Regards,
Satips.
|
|
|
|
|
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();
cmd.Parameters.AddWithValue("@id", 1);
cmd.CommandText = "Select * from Emp Where EmpId=@id";
Regards
Pankaj Joshi
|
|
|
|
|
but i am using dot net frame work 1.1 and there is not add with value
hello
|
|
|
|
|
Use this pattern:
OleDbParameter param = new OleDbParameter();<br />
param.DbType = DbType.Int32;<br />
param.Value = 15;<br />
<br />
command.Parameters.Add(param);
|
|
|
|
|
Those are MySql named parameters.
He uses Access I think.
|
|
|
|
|
private const string ConString ="Provider=MSDAORA;Data Source=ESPCS;User ID=espcs_users;Password=jtechusers;Persist Security Info=True";
private const string GetEmployeeByName= "select empno,name,grade,desgn,section from espcs.emp where status='T' and " +
" empno = @empno";
when i run this code it gives an exception "some error occured during processing of command"
public DataSet GetEmpByName(int name)
{
try
{
using (OleDbConnection con = new OleDbConnection (ConString))
{
con.Open ();
OleDbCommand com = new OleDbCommand (GetEmployeeByName ,con);
OleDbParameter par = new OleDbParameter ();
par.DbType = System .Data.DbType.Int32;
par.Value = name;
com.Parameters.Add(par);
OleDbDataAdapter dr = new OleDbDataAdapter (com);
DataSet ds = new DataSet ();
dr.Fill (ds);
return ds;
hello
|
|
|
|
|
Hi,
I don't why it giving error but I use same code as you use except I use the MSACCESS
as database and it is running successfully
public DataSet GetEmpByName(int empId)
{
string ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\test.mdb";
string GetEmployeeByName = "select * from Emp where Empid = @empno";
DataSet ds = new DataSet();
try
{
OleDbConnection con = new OleDbConnection(ConString);
con.Open();
OleDbCommand com = new OleDbCommand(GetEmployeeByName, con);
OleDbParameter par = new OleDbParameter();
par.DbType = System.Data.DbType.Int32;
par.Value = empId;
com.Parameters.Add(par);
OleDbDataAdapter dr = new OleDbDataAdapter(com);
dr.Fill(ds);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
return ds;
}
Regards
Pankaj Joshi
|
|
|
|
|
You Can also add the parameter name to like
par.ParameterName = "@empno";
Regards
Pankaj Joshi
|
|
|
|
|
Yes, I think that's the problem. When using the @param form you soulb also specify the parameter name. But if you use unnamed parameters: ?, then there's no need for that. You just have to add them in the right order.
|
|
|
|
|
I am designing a PDA application using the .NET CF, but I guess this issue would be the same irrespective of it being .NET Framework or .NET Compact Framework..
I have a button and I want to make it have like a button-down event. For example, a form has a mousedown and when the mouse button is down, there is an eventhandler mousedown for it.
I want my button to do the same. Note that the mousedown event doesn't exist for a button. Even setting a mousedown event on the form which contains the button doesn't do the trick (clicking the button does not fire the mousedown event of the form)..
what I want to do is have a facility in my application like while the button is being pressed (for example it can remain pressed for 5 seconds), keep changing the value of another control..
Any help would be highly appreciated.
Cheers,
David
|
|
|
|
|
What if you use the mouse down event and check for the position of the cursor to be inside your button. Wouldn't that have the same outcome?
|
|
|
|
|
I thought of that too.. But it doesn't help.. because when you click the button, the mousedown event of the form doesn't get fired
|
|
|
|
|
What makes you think the MouseDown event doesn't exist for a Button ?
According to the documentation, the MouseUp and MouseDown events are part of the Control class and supported in CF 1.0 and 2.0 as well.
Since Button inherits from Control , these events do exist.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Well.. I can't find them in the property window of the button. I have KeyDown, KeyUp and a bunch of other events but not MouseDown and MouseUp.
|
|
|
|
|
Sir,
I am writing a program that return the current file size in MB
my file size in bytes is 4,412,471 and windows shows it 4.20 MB.
for that I write following code
System.IO.FileInfo objNew = new System.IO.FileInfo("C:\\\\test.rar");
decimal val=objNew.Length / 1048576;
string str = String.Format("{0:F2}", val);
but when i print the str it shows 4.00 what is the problem ...?
I think when (objNew.Length / 1048576) execute it give 4 not 4.2 please give me solution
Regards
Pankaj Joshi
|
|
|
|
|
pankaj.indore wrote: decimal val=objNew.Length / 1048576;
change the above to:
decimal val=objNew.Length / 1048576m;
Try to discover why the avove solves
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
It running now...
What is the logic Behind that...?
Regards
Pankaj Joshi
|
|
|
|
|
The two operands of the division are both integers hence an integer division is performed, giving 0 as result (the latter is then converted to decimal type, but you've already lost your decimal digits ). By appending an m you force the compiler to interpeter the operand as a decimal and hence to perform a division between decimals yelding the correct result.
BTW the same chan be obtained explicitely casting one of the operands to decimal type, e.g.:
decimal val= (decimal)objNew.Length / 1048576;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
pankaj.indore wrote: decimal val=objNew.Length / 1048576;
AS the number on the right hand side of the operator is an int, it will return an int. Replace 1048576 with 1048576.00
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thx Sir,
its running now...
But what is the actual problem i can't get yet...?
i don't think their is a difference between 1048576.00 and 1048576
please clear it to me.
Regards
Pankaj Joshi
|
|
|
|
|
1048576 is a literal of the type int .
1048576.0 is a literal of the type double .
When you do a division where both operands are int , the result is an int .
When you do a division where one or both of the operands are double , the result is a double .
1048576m is a literal of type Decimal . I would suggest that you avoid the Decimal data type, unless you actually need it's higher precision. (Which you don't do in this case.)
---
single minded; short sighted; long gone;
|
|
|
|
|
Thx For your Reply,
I got the actual problem but still have a doubt see code below
Dim d as double
d=5/3
messagebox.show(k.tostring())
result 1.666666667
but in C# it give 1 whyyyyyyyyyyyyyyyy
I know your answer is int/int result int . but my dear friend type casting proves maths wrong...?
universe know this 5/3 = 1.666666....
why C# dosen't...?
Regards
Pankaj Joshi
|
|
|
|
|
pankaj.indore wrote: I know your answer is int/int result int . but my dear friend type casting proves maths wrong...?
universe know this 5/3 = 1.666666....
why C# dosen't...?
I don't remember much VB, but I think equivalent to 5/3 in C# is 5 div 3 in VB. Do you know the difference now?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|