471,309 Members | 1,077 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Connecting to a SQL server

Good morning, all.

First I want to apologize for the cross-posting, but this is a major part of
the project and I would use an advice fastly.

I am trying to design a Web app using C# to attach to a SQL server.

As a test, I created a SQL connection and it tested successfully.

This is my problem:

I created a text box (txtName) which I need to bound to a specific field in
the SQL database but I can't find it in the textbox property.

Can someone point me to the right direction?

Thanks,
Antonio
Dec 7 '05 #1
6 1059
TextBox control, whether Winforms or ASP.NET, has a Text property that holds
the current value the user typed in, or which you have set programmatically,
e.g.

textBox1.Text is the value you want to insert into your SQL Table. Is this
what you are looking for? Your post doesn't have that much information.

-Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Antonio" wrote:
Good morning, all.

First I want to apologize for the cross-posting, but this is a major part of
the project and I would use an advice fastly.

I am trying to design a Web app using C# to attach to a SQL server.

As a test, I created a SQL connection and it tested successfully.

This is my problem:

I created a text box (txtName) which I need to bound to a specific field in
the SQL database but I can't find it in the textbox property.

Can someone point me to the right direction?

Thanks,
Antonio

Dec 7 '05 #2
Antonio,

You don't bind columns directly to controls in .NET.

What you do is create a SqlDataAdapter, which has insert, update,
delete, and select commands for your table.

You then fill a dataset with the adapter (through the Fill method). You
bind that do your TextBox through the Bindings propery.

Your textbox is then bound to the dataset. When you are done with it,
you can pass the data set to the data adpater through the Update method.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Antonio" <ap*********@pascarellas.com> wrote in message
news:au********************@comcast.com...
Good morning, all.

First I want to apologize for the cross-posting, but this is a major part
of the project and I would use an advice fastly.

I am trying to design a Web app using C# to attach to a SQL server.

As a test, I created a SQL connection and it tested successfully.

This is my problem:

I created a text box (txtName) which I need to bound to a specific field
in the SQL database but I can't find it in the textbox property.

Can someone point me to the right direction?

Thanks,
Antonio

Dec 7 '05 #3
Hi, Peter, thank you for your reply.

What I meant was that I am creating a web app and I need the textboxes to
get the data from a sql server. And also, add records, update records, etc.

But the primary value is what's retrieved from the sql.

Antonio

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:0A**********************************@microsof t.com...
TextBox control, whether Winforms or ASP.NET, has a Text property that
holds
the current value the user typed in, or which you have set
programmatically,
e.g.

textBox1.Text is the value you want to insert into your SQL Table. Is this
what you are looking for? Your post doesn't have that much information.

-Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Antonio" wrote:
Good morning, all.

First I want to apologize for the cross-posting, but this is a major part
of
the project and I would use an advice fastly.

I am trying to design a Web app using C# to attach to a SQL server.

As a test, I created a SQL connection and it tested successfully.

This is my problem:

I created a text box (txtName) which I need to bound to a specific field
in
the SQL database but I can't find it in the textbox property.

Can someone point me to the right direction?

Thanks,
Antonio

Dec 7 '05 #4
Hi,

I created a text box (txtName) which I need to bound to a specific field
in the SQL database but I can't find it in the textbox property.
Most probably your query will return more than one row, how you are dealing
with this?

As the other posters (nicholas ) said you need to load it first in a
dataset/datatable then you can bind it to the textbox.

As you saw the textbox itself does not support binding , you have to assign
the value directly using TextBox.Text or in the aspx page using <%# %> tags
..
btw, if you are going to cross-post (which you should not ! ) select the
correct groups , posting to
microsoft.public.dotnet.languages.vc,microsoft.pub lic.dotnet.vc.general as
nothing to do with the problem at hand

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Can someone point me to the right direction?

Thanks,
Antonio

Dec 7 '05 #5
using System.Data.SqlClient

should help :-)

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schrieb im Newsbeitrag news:e8**************@TK2MSFTNGP14.phx.gbl...
Hi,

I created a text box (txtName) which I need to bound to a specific field
in the SQL database but I can't find it in the textbox property.
Most probably your query will return more than one row, how you are

dealing with this?

As the other posters (nicholas ) said you need to load it first in a
dataset/datatable then you can bind it to the textbox.

As you saw the textbox itself does not support binding , you have to assign the value directly using TextBox.Text or in the aspx page using <%# %> tags .
btw, if you are going to cross-post (which you should not ! ) select the
correct groups , posting to
microsoft.public.dotnet.languages.vc,microsoft.pub lic.dotnet.vc.general as
nothing to do with the problem at hand

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Can someone point me to the right direction?

Thanks,
Antonio


Dec 22 '05 #6
What do you guys mean by "...As you saw the textbox itself does not
support binding..."? It does support binding to a datatable as any other
control does.

txtBox.DataBindings.Add("Text", drDataRow, "Data table's column name");

Works for me in 1000 places in our app...

Let me know if you need any more explanation

MuZZy


MasterChief wrote:
using System.Data.SqlClient

should help :-)

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schrieb im Newsbeitrag news:e8**************@TK2MSFTNGP14.phx.gbl...
Hi,

I created a text box (txtName) which I need to bound to a specific field
in the SQL database but I can't find it in the textbox property.

Most probably your query will return more than one row, how you are

dealing
with this?

As the other posters (nicholas ) said you need to load it first in a
dataset/datatable then you can bind it to the textbox.

As you saw the textbox itself does not support binding , you have to

assign
the value directly using TextBox.Text or in the aspx page using <%# %>

tags
.
btw, if you are going to cross-post (which you should not ! ) select the
correct groups , posting to
microsoft.public.dotnet.languages.vc,microsoft.pub lic.dotnet.vc.general as
nothing to do with the problem at hand

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Can someone point me to the right direction?

Thanks,
Antonio


Dec 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ann Marinas | last post: by
6 posts views Thread by Todd Brewer | last post: by
10 posts views Thread by mairhtin o'feannag | last post: by
reply views Thread by rosydwin | last post: by

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.