|
private void button1_Click(object sender, System.EventArgs e)
{
System.Data.OleDb.OleDbDataReader myReader;
string CustomerString;
oleDbConnection1.Open();
myReader=oleDbCommand1.ExecuteReader();//"I get the error here "System.InvalidOperationException:No data exists for the row/column"
//But I just rechecked the data inside the Access database file and data is there.
try
{
//Retrieves the first and last names from Customers and
//concatenates them into a single string
CustomerString=myReader[1].ToString() + " " +
myReader[2].ToString();
//adds the string to the ListBox
listBox1.Items.Add(CustomerString);
}
catch(Exception e1)
{
MessageBox.Show(e1.ToString());
}
myReader.Close();
oleDbConnection1.Close();
}
|
|
|
|
|
T4AMD wrote: But I just rechecked the data inside the Access database file and data is there.
What data ? I mean, where is the code that defines a command to send to your database ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source="F:\Windows\Chapter6Solution\Chapter6Project\The Doughnut Shop.mdb";Mode=Share Deny None;Jet OLEDB:Engine Type=5;Provider="Microsoft.Jet.OLEDB.4.0";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1
This is my code. This project is in .NET Framework 1.1 so this connectionstring is in the Properties retrieving data from Access Database
|
|
|
|
|
That's a connection string repeated over and over. I still don't see any SQL.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
I don't see a query string in oleDbCommand1 . That might be your problem... Or is the query in the Properties somewheres?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
SELECT * FROM Customers...This query for OleDBCommand1 is actually embedded in the properties
|
|
|
|
|
I know this might be silly, but is there data in the table?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
yeah..there is data in the Access Database
|
|
|
|
|
I want to hide the tree in the report viewer
merwa
|
|
|
|
|
go to the properties section of Crystal Report viewer and enable
displaygrouptree to false
|
|
|
|
|
go to property window and set displaygrouptrees to false
|
|
|
|
|
Hello,
Does anyone have the code to make a timer count up on a label? I think it has something to do with 'parse', but I'm not sure...
thanks, now MS
|
|
|
|
|
Hi , Did you mean This ?
public int x;<br />
<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
x = 0;<br />
timer1.Enabled = true;<br />
timer1.Interval = 1000;<br />
}<br />
<br />
private void timer1_Tick(object sender, System.EventArgs e)<br />
{<br />
x++;<br />
label1.Text = x.ToString();<br />
}<br />
I know nothing , I know nothing
|
|
|
|
|
Hang on I'll give it a shot... If it's that simple...
|
|
|
|
|
HOW IS IT THAT SIMPLE??? THANKYOU, BUT LORD!! i LOOKED ALL over the freakin web and found hard stuff, and then there's this... I've benn looking a while now, so thankyou so much!
MasterSharp (not REALLY a master...)
|
|
|
|
|
I have network access to machines on the domain via remote desktop connection. I am trying to see if there is a way using C# to write an application that allows me to logon to the machine in such a way that it would allow me to check if a process is in memory.
Essentially I am trying to automate the process of checking to see if an executable that is supposed to be running is in fact running on 20 or so different machines without having to use Remote Desktop to login and physically inspect them.
Can someone point me in the right direction if it is possible?
|
|
|
|
|
You can use the Process.GetProcesses()[^] method. This method will use the same credentials as the user than runs your C# application. This user would need to have permissions to list processes on the remote box. In addition, there's a problem[^] with listing processes on certian windows boxes.
You can impersonate another user in C# as described here[^].
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
That's cool. I didn't know Process.GetProcesses could get the processes of a remote machine. I thought it was limited to where the exe was run from. "The More You Know..."
|
|
|
|
|
Hi there, I'm a new bie to C# still learning about it. Everything that i've read about the SET and GET method, I don't seem to understand and understand the purpose of its use and when to use it in an application. I was wondering if some one could help me. Any sample code that I've downloaded using this method so I can debug through it to hopefully understand dosen't work. I'm using .net framework 2.0. I've got some of the following code below that i've adapted to test it. I have a web form with a button and label on it when you click on the button :
DEFAULT.ASPX
protected void Button1_Click(object sender, EventArgs e)
{
int i;
prop iage = new prop();
iage.age = 5;
Label1.Text = iage.age;
}
PROP.CS
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///
/// Summary description for properties
///
public class prop
{
public prop()
{
//
// TODO: Add constructor logic here
//
}
private int age = 0
public int age
{
get
{
return age;
}
set
{
age = value;
}
}
Thankyou
|
|
|
|
|
You can't give the private variable age the same name as the public property age. Consider renaming your private variable to something like _age.
You would have seen this error returned by the compiler though, right?
Regards
Paul
|
|
|
|
|
pmarfleet wrote: Consider renaming your private variable to something like _age.
Consider also sticking to the Microsoft guidelines that say that public properties use Pascal naming convention while private fields use camel case.
|
|
|
|
|
Thankyou Paul, i did get an error stating that your using the property name more than once.
|
|
|
|
|
get/set methods are called properties. They are syntactic sugar to allow you to hide the details of members, and provide the equivalents of methods to retrieve or set the value of those methods. So, what do I mean by this? Well you could view each get/set property as really being two methods; one is set_property and the other one is get_property.
Why would you do this? Well - properties allow you to encapsulate/hide members. Instead of providing you with direct access to the members, properties abstract your access. This means that you can leave implementation details for working with the members. For instance, suppose that you want to ensure that a string is of a certain length then you can do this like:
private string _myString;
public string MyString
{
get { return _myString ; }
set
{
if (value != null && value.Trim().Length > 30)
value = value.Substring(0, 30);
_myString = value;
}
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thankyou Pete, that is really helpful. So if we use your example above i believe instead of having the if statement in the back of the web form where it can be accessed by anyone and needed to be rewritten for other similar cases we know lock down the access to the data and also reduces the amount of redundant code. Have I correctly understood the purpose of this.
Thankyou
|
|
|
|
|
You have - although it offers more. Suppose that you want to change the length that is allowed - instead of having to search through every piece of code that calls this and change the length there, you can do it in one place here. Also, you can create a simple "dirty" check by doing:
public class MyClass
{
private string _myString = string.Empty;
private int _myInt = 0;
private bool _isDirty = false;
public string MyString
{
get { return _myString ; }
set
{
if (_myString != value)
{
_myString = value;
_isDirty = true;
}
}
}
public int MyInt
{
get { return _myInt; }
set
{
if (_myInt != value)
{
_myInt = value;
_isDirty = true;
}
}
}
public bool IsDirty
{
get { return _isDirty; }
}
public void Save()
{
_isDirty = false;
}
} This is only one example of the type of thing that you can do with properties.
Deja View - the feeling that you've seen this post before.
|
|
|
|