|
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data source= C:/data.accdb;User Id=admin;Password=";
string sql = "SELECT UserName, UserPassword FROM TblUsers";
OleDbCommand cmd = new OleDbCommand(sql, conn);
OleDbDataReader dbReader = cmd.ExecuteReader();
dbReader = cmd.ExecuteReader();
while (dbReader.Read())
{
UserName = dbReader.GetString(3).ToString();
PassWord = dbReader.GetString(4).ToString();
}
dbReader.Close();
conn.Close();
i have an error in the Data Reader. the error lies in,OleDbDataReader dbReader = cmd.ExecuteReader(); adn it say it has no value given for one or more parameters. I have ask my friends and they say the problem is the,string sql = "SELECT UserName, UserPassword FROM TblUsers";
so now i know that the problem lies in the string sql.
but i do not know what to change in the string.
can anyone help?? :S
i will really appreciate it! thank you.
|
|
|
|
|
You have not opened the database connection.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
You also call cmd.ExecuteReader twice. What are you trying to do here ? Are you trying to learn C# ? If you don't know any SQL, shouldn't you just learn C# first, then try working with databases ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
and you shouldn't store passwords as plain text. Encrypt them.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi,
I want to add image in picture box with the help of code not wizard.
Please help
|
|
|
|
|
MSDN would tell that. Read about PictureBox class.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
bhai i know u are a very good fool& idiot.
i expect u that type of answer.
|
|
|
|
|
You're obviously an utter moron. You really think that's the way to talk to people ? If you're incapable of reading the most basic documentation, then what you got is the sort of answer you deserve, and you should not pretend to have any aptitude for any sort of job that requires intelligence, programming included.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
A deserving candidate for your new blog.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
MSDN can help you,please do it yourself!
|
|
|
|
|
I guess you replied to wrong post.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
that is not going to be easy. The solution probably contains complex statements such as:
myCrappyPictureBoxIDRatherNotUseAtAll1.Image=theBeautifulImageIGotFromICantRememberWhere;
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hai.....im anu..
can u ppl help me plzz.......im doing..Merge Word documents into one file...i wrote code lik below...i create a place (D:/destination/new.doc)..wher my documents ill open....in debugging whn i clik on merge button no files showing in "D:/destination/new.doc"....
im a fresher 4r dotnet .... hope u ll understnd my lang....
Thanqu ....
namespace DocMerger
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
List<string> files=new List<string>();
DialogResult dr = new DialogResult();
dr = openFile.ShowDialog();
if (dr == DialogResult.OK)
{
listView1.Items.Clear();
files.AddRange(openFile.FileNames.ToList());
foreach (string file in files)
{
listView1.Items.Add(Path.GetFileName(file));
}
}
}
private void button2_Click(object sender, EventArgs e)
{
DocMerger db=new DocMerger();
string path="D:/source/";
string output="D:/destination/new.doc";
string temp="D:/destination/temp.doc";
db.CopyMerge(temp,path,output);
}
}
}
|
|
|
|
|
anu gunturi wrote: im a fresher 4r dotnet .... hope u ll understnd my lang....
Then why are you doing this instead of something more straightforward ? It looks like you're using a third party component to do this. Where is it not working ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi..
i want to take average of different price of same product..
For Example
i perches a Oil in different prices i want to show the average of Oil price.
hope u understand my problem
thanks in advance
jawad khatri
|
|
|
|
|
Sounds like basic maths to me. Is it homework ? What have you tried ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
what did you try? where did you stuck?
please be specific with your questions, so that it will be easy to get answers...
AFAIK, avg = sum / no_of_items;
was this your question???
Have a Happy Coding.....
|
|
|
|
|
There is an ActiveX dll in C++ that has some function:
void function(unsigned char* buffer, unsigned long* size);
I added its reference in C# project from COM components tab.
However in C# function it is defined as
void function(out byte buffer, out uint size);
The dll just writes to buffer some bytes array of specific size.
How can we pass that allocated byte[] array to C# implementation?
Чесноков
|
|
|
|
|
Hi,
I'm not sure it works the same for ActiveX, however using P/Invoke to call a native code function I would use:
- either the pointer to a pinned byte array (for binary data);
- or a StringBuilder with a sufficient capacity (for ANSI or Unicode text).
Here are two ways to handle an array (example uses int array, similar for byte[]):
unsafe public int ArrayFixed() {
int dim=1000;
int[] numbers=new int[dim];
...
int sum;
fixed (int* pNumbers=&numbers[0]) {
sum=SumArray(pNumbers, dim);
}
return sum;
}
[DllImport("native.dll")]
unsafe public static extern int SumArray(int* pNumbers, int count);
and
public int ArrayHandle() {
int dim=10000;
int[] numbers=new int[dim];
...
GCHandle handle=GCHandle.Alloc(numbers, GCHandleType.Pinned);
int sum=SumArray(handle.AddrOfPinnedObject(), dim);
handle.Free();
return sum;
}
[DllImport("nativeC.dll")]
public static extern int SumArray(IntPtr pNumbers, int count);
Note: no out keyword is used for arrays.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hello.
What is the use of COM registered component? If you can not use them as a reference module added to the project?
The definition of the function in metadata is different than in C++. It takes just 1 byte instead of bytes array.
Is that just the programmers failure or there is a way to pass to out byte buffer a byte[] array ??
Чесноков
|
|
|
|
|
if it is just one byte then out byte buffer would be fine, but then buffer isn't the best name for it.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi All,
Please tell me how to write XML query in Asp.net.
I hav temple.xml file which contain data of temple.
now i want to apply search on it.
|
|
|
|
|
Load the XML file into XmlDocument instance and write XPath[^] query.
Best wishes,
Navaneeth
|
|
|
|
|
The ASP.NET part is irrelevant. You want to use C#. So, what version of C# do you have ? That will determine if you want to use LINQ or if you need to use the XMLDocument class.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
public class MyClass
{
private string _MyProperty = "the property";
[colName="theColumn"]
public string MyProperty
{
get { return _MyProperty; }
set { _MyProperty = value; }
}
public string GetName()
{
// code to implement
}
}
public class MyClassTest
{
MyClass c=new MyClass();
// I want to get the attribute in the following way:
string colName= c.MyProperty.GetName();
//colName should be theColumn
}
any kind of help would be appriciated.
and it should be in .NET 2.0 framework
|
|
|
|