select string for oleDB

D

Doug

Hi

I posted an hour ago from a different pc - about calling a form from another
form.

now i am having trouble passing the value from a text box (called
tb.entryData), from the form called input.cs (referenced as an object as
input simple=new input();) to my select string.

My code is below

private void btnSimple_Click(object sender, EventArgs e)

{

lbCustomers.Text = "";

input simple = new input();

simple.Show();



// simple has a text box and a button. The text box is called tb.entryData
and its value is passed to a public string called inputs

// i would like the value passed into the commandString to use as a querie.



string commandString = "SELECT vars.label, vars.file, vars.wave, vars.name
FROM vars where var.label like '%' + simple.inputs";

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\hilda helpa - confidentialised.mde";

OleDbDataAdapter DataAdapter = new OleDbDataAdapter(commandString,
connectionString);


DataSet DataSet = new DataSet();

try

{

DataAdapter.Fill(DataSet, "vars");

}

catch (Exception ex)

{

MessageBox.Show("Error: " + ex);

return;

}

DataTable dataTable = DataSet.Tables[0];

foreach (DataRow dataRow in dataTable.Rows)

{

lbCustomers.Items.Add(dataRow["file"] + " " + dataRow["name"]+ " " +
dataRow["label"] +" " + dataRow["wave"]);

}

}



Any assistance appreciated.



Doug
 
G

Guest

It would be helpful to know what error you are getting, but I think you are
going to need a couple of more parameters in your connection string: Initial
catalog(aka Database), and I think Access makes you use UserId (aka UID), and
Password (aka PWD). If not those two parameters you'll need something like
Integrated Security=SSPI.

And by the way yes I KNOW it's not a good idea to pass UID/PWD. ;)

HTH

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
 
D

Doug

The other parameters are not required as i can run this without the where
clause.

I just like to know how to pass the parameter from a text box to the select
string.

Doug
WhiteWizard said:
It would be helpful to know what error you are getting, but I think you
are
going to need a couple of more parameters in your connection string:
Initial
catalog(aka Database), and I think Access makes you use UserId (aka UID),
and
Password (aka PWD). If not those two parameters you'll need something
like
Integrated Security=SSPI.

And by the way yes I KNOW it's not a good idea to pass UID/PWD. ;)

HTH

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT


Doug said:
Hi

I posted an hour ago from a different pc - about calling a form from
another
form.

now i am having trouble passing the value from a text box (called
tb.entryData), from the form called input.cs (referenced as an object as
input simple=new input();) to my select string.

My code is below

private void btnSimple_Click(object sender, EventArgs e)

{

lbCustomers.Text = "";

input simple = new input();

simple.Show();



// simple has a text box and a button. The text box is called
tb.entryData
and its value is passed to a public string called inputs

// i would like the value passed into the commandString to use as a
querie.



string commandString = "SELECT vars.label, vars.file, vars.wave,
vars.name
FROM vars where var.label like '%' + simple.inputs";

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\hilda helpa - confidentialised.mde";

OleDbDataAdapter DataAdapter = new OleDbDataAdapter(commandString,
connectionString);


DataSet DataSet = new DataSet();

try

{

DataAdapter.Fill(DataSet, "vars");

}

catch (Exception ex)

{

MessageBox.Show("Error: " + ex);

return;

}

DataTable dataTable = DataSet.Tables[0];

foreach (DataRow dataRow in dataTable.Rows)

{

lbCustomers.Items.Add(dataRow["file"] + " " + dataRow["name"]+ " " +
dataRow["label"] +" " + dataRow["wave"]);

}

}



Any assistance appreciated.



Doug
 
Top