|
Hi, I have a ComboBox to which I give a string array as a DataSource. It works. I also have a DataSet and one of the columns of a table contains the SelectedIndex of this ComboBox, but when I bind it, it does not select the right index.
I've decided to bind it to a numericUpDown and it works, so what's going on with the comboBox?
Here's my code:
numericUpDown1.DataBindings.Add("Value", dataset.LoadModule, "RampUpSpeed");<br />
<br />
rampUpCombo.DataBindings.Add("SelectedIndex", dataset.LoadModule, "RampUpSpeed");
Thanks!
|
|
|
|
|
hey all,
I'm tring to pull records from an access database in my c#.net web app.
Doing it using VS2005 in the gui view is fine but I want to set up a connection server side and pull records using a reader like I would with sql, however, I can't seem to find the syntax. I have created the connection string but from there on it seems quite a bit different from an sqlconnection.
I'm after the equivilant of below:
//------
OleDbConnection dbConnect = new OleDbConnection(@"Dsn=MS Access Database;dbq=C:\Program Files\Sage\Accounts\DBFile.mdb;defaultdir=C:\Program Files\Sage\Accounts;driverid=25;fil=MS Access;maxbuffersize=2048;pagetimeout=5;uid=manager");
OleDbCommand dbcommandCom = new OleDbCommand(@"select * from [invoice]");
dbConnect.Open();
OleDbDataReader RecReader = null;
dbConnect.Open();
RecReader.Read();
dbConnect.Close();
//-----------
Can someone please help as I have a short timescale for the project.
Thanks in advance
mark
|
|
|
|
|
Basically, I believe you call Read over and over, and each time you do, the reader points to the next record, and you can access the columns of that row before calling read again.
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 )
|
|
|
|
|
It looks like you create a connection object, a command object and a reference for a data reader, and hope that they will automatically find each other, execute the command, create a data reader object and place in your reference. They don't. You have to make the command object use the connection, then you have to use a method in the command object like ExecuteReader to execute the command, and assign it's return value to your reference. Then you can start to read from it.
Look at any examples out there. They are everywhere.
markymark82 wrote: I have created the connection string but from there on it seems quite a bit different from an sqlconnection.
On the contrary. From there on the code is very similar.
---
single minded; short sighted; long gone;
|
|
|
|
|
ok,
so should I actually be using the 'OleDbConnection', as currently I keep getting errors about the provider for it, the only suggestion i've found is 'provider=sqloledb;' in the connection string, but obviously its not an sql db so that doesn't work, what would the equivilant be for an ms access db?
Otherwise the only other connection object I have found that does not error is:
'AccessDataSource db = new AccessDataSource(@"Dsn=MS Access Database;dbq=C:\Program Files\Sage\Accounts\ODBC.mdb;defaultdir=C:\Program Files\Sage\Accounts;driverid=25;fil=MS Access;maxbuffersize=2048;pagetimeout=5;uid=manager", @"select * from Invoice");'
but from there I have no idea how to open a reader as I can't find an option for it and I can't see how to read the records that are returned from it?
thanks for you help so far, much appreciated
mark
|
|
|
|
|
Open the properties for the connection that you are using in Visual Studio. There you will see the provider and connection string.
Otherwise connectionstrings.com[^] is good for connectionstrings.
OleDb is the preferred provider for Access.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for the help,
I really appreciate it.
I shall try that outbut for now I have found a way slightly around the problem.
I have created a system odbc object that links to the .mdb file and then linked to it through odbcconnection. This has worked fine for now but I'll still try doing it the other way as i wont have to create odbc objects on each machine its to be installed on.
thanks again
mark
|
|
|
|
|
hi,
i've made an app on my pc who pings to see who's in my network and is able to send emails
i want to do the same on a pocket pc, but i cant seem to find how this works
i get stuck on the fackt that pocket pc in vs 2005 doesn't have :
using System.Net.NetworkInformation;
using System.Web.Mail;
does anybody know were i can find examples or how i send emails or ping ???
plz help!
grz muk
|
|
|
|
|
Hi,
i've created a setup project and it works fine. Now i want to retrieve the installation path because i need to set it as current directory for the windows service i've created. How can i do it?
I need to pass through windows registry (how?) or exists a variable or a property which i can read?
Thank you all!
Gianluca
|
|
|
|
|
[TARGETDIR] is the property which contains the installation directory.
You can add registry keys via the installer.
|
|
|
|
|
terrible83 wrote: because i need to set it as current directory for the windows service i've created
As someone pointed out in the past few days, best practice is to use absolute paths.
To obtain the path you can access the installation path using the Windows Installer SDK in your service, that is what you are asking correct? However AFAIK this should work:
System.Reflection.Assembly.GetExecutingAssembly().Location
|
|
|
|
|
Hi
Im doing an application in Visual C# 2005, my application can read data from my database but cant save into the database. Heres the code. What am I missing....Pliz Help!!!!
private void btnSave_Click(object sender, EventArgs e)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source=YAC.mdb";
OleDbConnection conn = new OleDbConnection(strConnection);
conn.Open();
string strCommand = "INSERT INTO ClientProfile(Name,Surname,Gender,IdNumber) Values ('" + txtName.Text + "','" + txtSurname.Text + "','" + cbxGender.Text + "','" + txtIdNumber.Text + "')";
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.InsertCommand = new OleDbCommand(strCommand, conn);
(this.yACDataSet.ClientProfile);
int t1 = adapter.InsertCommand.ExecuteNonQuery();
conn.Close();
if (t1 > 0)
{
MessageBox.Show("added successfully!");
}
csanda
|
|
|
|
|
|
I'm trying to query the registry on a remote server to verify a value. using the code
<br />
RegistryKey RemoteKey;<br />
string RemoteComputer = LabName + "isp0001";<br />
RemoteKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, RemoteComputer);<br />
string value = RemoteKey.OpenSubKey("SOFTWARE\\Twrap\\Packages\\Completed", RegistryKeyPermissionCheck.ReadSubTree).GetValue("1.3", 0).ToString();<br />
<br />
When i run it i see this:
A first chance exception of type 'System.NullReferenceException' occurred in LabMonitor.exe
A first chance exception of type 'System.NullReferenceException' occurred in LabMonitor.exe
and the exception message is: "Object reference not set to an instance of an object"
Please help
|
|
|
|
|
StevenWalsh wrote: and the exception message is: "Object reference not set to an instance of an object"
You're bound to get that when you chain together calls without first checking the return values. I'd assume that OpenSubKey is failing, but you should step through and check it yourself, and write more defensive code in future.
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 )
|
|
|
|
|
Hello Steven,
either the RemoteKey is null or
the "RemoteKey.OpenSubKey("SOFTWARE\\Twrap\\Packages\\Completed", RegistryKeyPermissionCheck.ReadSubTree)" is null
change your code from:
RegistryKey RemoteKey;<br />
string RemoteComputer = LabName + "isp0001";<br />
RemoteKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, RemoteComputer);<br />
string value = RemoteKey.OpenSubKey("SOFTWARE\\Twrap\\Packages\\Completed", RegistryKeyPermissionCheck.ReadSubTree).GetValue("1.3", 0).ToString();
to:
RegistryKey RemoteKey;<br />
RegistryKey RemoteSubKey;<br />
string value;<br />
string RemoteComputer = LabName + "isp0001";<br />
RemoteKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, RemoteComputer);<br />
if (RemoteKey != null)<br />
{<br />
RemoteSubKey = RemoteKey.OpenSubKey("SOFTWARE\\Twrap\\Packages\\Completed",RegistryKeyPermissionCheck.ReadSubTree);<br />
if (RemoteSubKey != null)<br />
{<br />
value = RemoteSubKey.GetValue("1.3", 0).ToString();<br />
}<br />
}<br />
if (value != null && value.Length>0)<br />
{<br />
}
GanDad
|
|
|
|
|
Hi, i've tried your code, and i'm still getting the exception here is where it is stopping
RemoteKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, RemoteComputer);
|
|
|
|
|
Breaking it down will just help you work out where the problem is. It won't change that you are making a call which is returning null, and not checking it.
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 )
|
|
|
|
|
Christian Graus wrote: Breaking it down will just help you work out where the problem is. It won't change that you are making a call which is returning null, and not checking it.
i broke it down some more and narrowed to problem down to the string "value" i made value an object datatype and it now works.
|
|
|
|
|
|
Thats a nice specific specification so just impliment it.
You need only the most basic knowledge of c# to achive this.
|
|
|
|
|
i am in a short period of time and i do have problem on my computer..i can't practice now..i find source of this project and i try this site that someone could help me to this problem..
......
|
|
|
|
|
So because it's got to be handed in soon and you didn't do it in time you want someone else to do it for you?
|
|
|
|
|
every homework request comes with a sob story. This is really straight forward. If you try to do it yourself and you need help with specific things, that's different, but for you to just post your homework and hope someone will do it is, frankly, kind of rude.
So, I ask again, which specific bits are confusing you ? Do you want to ask some specific questions to help you in approaching this task ?
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 )
|
|
|
|
|
Which part of your (pretty simple) homework is confusing you ? This is a basic exercise in OO. We never do homework, but this in particular, is pretty vital for you to understand, and really not hard.
I would guarentee that any text you've been assigned will cover all you need to know to do this.
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 )
|
|
|
|