473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

select string for oleDB

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
Jul 27 '06 #1
3 5607
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" wrote:
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
Jul 27 '06 #2
Hi,

What error exactly are you getting?

Are you sure that is the correct connection string? Try this site:
http://www.connectionstrings.com/ you will find a connection string to
almost all data sources

Also note that your code is prone to Injection Attacks :
http://en.wikipedia.org/wiki/SQL_injection_attack
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Doug" <qu********@hotmail.comwrote in message
news:44***********************@news.optusnet.com.a u...
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


Jul 27 '06 #3
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" <Wh*********@discussions.microsoft.comwrote in message
news:8F**********************************@microsof t.com...
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" wrote:
>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

Jul 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: atse | last post by:
Hi, I tried to make select query to a text file using the code below, <% sconnection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="D:\myforlder\;Extended...
2
by: jez123456 | last post by:
Hi I'm attempting to pass a string into another string but I get an error This code work ok jro.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Compact.mdb",...
1
by: PCK | last post by:
I am trying to select a single cell from an Excel workbook. I am using the following code. strCN = GetExcelConnection("C:\Test\Excel.xls") strCMD = "select * from " oleDbCN = New...
6
by: Carlo B | last post by:
Hi I need to use a listbox to display authors from the authors table in the standard BIBLIO.MDB. I haven't even got to this point yet and the code below is bombing out on the line...
7
by: Peter Proost | last post by:
Hi, I'm creating an import module to read data from old textfiles, run some calculations on them and save them to sql server. I've figured out how to do a select on textfile using a schema.ini file...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
4
by: tshad | last post by:
I have a program that is reading a .csv file into a dataset and works fine except that it is dropping the first line. I assume that is because it is dropping the header. The problem is the first...
1
by: veenna | last post by:
How can i select utf-8 encoded character fro ma text file and bind it to dataset. Here is the code: Dim srStreamReader As StreamReader Dim sFile As String = "E:\FTPROOT\uni.txt" Dim swfile As...
6
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.