how to select or update data when column name has space

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, everyone:

I am writing an ado.net componet in c# to fetch data from MS Acess database.

I got a problem is some table has column with space, such as "company name",

Could anyone tell me how to select this kind of column?

sincerely,

haiwen
 
Hello, Ryan:

Thanks for your reply. I used it, such as:
s="select [Company name],CompanyID from companies order by CompanyID asc";
OleDbDataAdapter adapter=new OleDbDataAdapter(s,con);

adapter.Fill(ds);

But I always get follow exception:

System.Data.OleDb.OleDbException: No value given for one or more required
parameters.

what's wrong I have done?
Sincerely,

haiwen
W.G. Ryan eMVP said:
use [Company Name]

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
haiwen said:
Hello, everyone:

I am writing an ado.net componet in c# to fetch data from MS Acess database.

I got a problem is some table has column with space, such as "company name",

Could anyone tell me how to select this kind of column?

sincerely,

haiwen
 
I'm not sure, I just whipped up and table and can't replicate it. If you
just use CompanyID in the query, does it work?

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
haiwen said:
Hello, Ryan:

Thanks for your reply. I used it, such as:
s="select [Company name],CompanyID from companies order by CompanyID asc";
OleDbDataAdapter adapter=new OleDbDataAdapter(s,con);

adapter.Fill(ds);

But I always get follow exception:

System.Data.OleDb.OleDbException: No value given for one or more required
parameters.

what's wrong I have done?
Sincerely,

haiwen
W.G. Ryan eMVP said:
use [Company Name]

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
haiwen said:
Hello, everyone:

I am writing an ado.net componet in c# to fetch data from MS Acess database.

I got a problem is some table has column with space, such as "company name",

Could anyone tell me how to select this kind of column?

sincerely,

haiwen
 
That error sounds like your datatset that you are filling with the
adapter.Fill(ds) doesn't allow NULLS in one of the columns and one of your
columns is returning null. Make sure that the dataset column "Company Name"
with a space exists. It might not be exactly the same name so it is
inserting nulls into it for every Company ID.

--
Eric Renken
Demiuirge Software LLC
http://www.demiurge.us


haiwen said:
Hello, Ryan:

Thanks for your reply. I used it, such as:
s="select [Company name],CompanyID from companies order by CompanyID
asc";
OleDbDataAdapter adapter=new OleDbDataAdapter(s,con);

adapter.Fill(ds);

But I always get follow exception:

System.Data.OleDb.OleDbException: No value given for one or more required
parameters.

what's wrong I have done?
Sincerely,

haiwen
W.G. Ryan eMVP said:
use [Company Name]

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
haiwen said:
Hello, everyone:

I am writing an ado.net componet in c# to fetch data from MS Acess database.

I got a problem is some table has column with space, such as "company name",

Could anyone tell me how to select this kind of column?

sincerely,

haiwen
 
Hi, thanks for your replies,

if I use:

select companyID from
or
select * from

it will work.

My dataset is a new empty dataset.

but if I use
select [company name] from

I will get the error information, it seems the command doesn't support []

Any idea?

Because I don't want to select all of columns and use the index, it is a
huge table.

Thanks a lot.

haiwen


Eric Renken said:
That error sounds like your datatset that you are filling with the
adapter.Fill(ds) doesn't allow NULLS in one of the columns and one of your
columns is returning null. Make sure that the dataset column "Company Name"
with a space exists. It might not be exactly the same name so it is
inserting nulls into it for every Company ID.

--
Eric Renken
Demiuirge Software LLC
http://www.demiurge.us


haiwen said:
Hello, Ryan:

Thanks for your reply. I used it, such as:
s="select [Company name],CompanyID from companies order by CompanyID
asc";
OleDbDataAdapter adapter=new OleDbDataAdapter(s,con);

adapter.Fill(ds);

But I always get follow exception:

System.Data.OleDb.OleDbException: No value given for one or more required
parameters.

what's wrong I have done?
Sincerely,

haiwen
W.G. Ryan eMVP said:
use [Company Name]

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
Hello, everyone:

I am writing an ado.net componet in c# to fetch data from MS Acess
database.

I got a problem is some table has column with space, such as "company
name",

Could anyone tell me how to select this kind of column?

sincerely,

haiwen
 
Back
Top