Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / December 2005

Tip: Looking for answers? Try searching our database.

Connecting to a SQL server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Antonio - 07 Dec 2005 13:08 GMT
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
Peter Bromberg [C# MVP] - 07 Dec 2005 13:13 GMT
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
Signature

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

> Good morning, all.
>
[quoted text clipped - 15 lines]
>
> Antonio
Antonio - 07 Dec 2005 14:00 GMT
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

> TextBox control, whether Winforms or ASP.NET, has a Text property that
> holds
[quoted text clipped - 28 lines]
>>
>> Antonio
Nicholas Paldino [.NET/C# MVP] - 07 Dec 2005 13:13 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Good morning, all.
>
[quoted text clipped - 15 lines]
>
> Antonio
Ignacio Machin ( .NET/ C# MVP ) - 07 Dec 2005 13:59 GMT
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.public.dotnet.vc.general as
nothing to do with the problem at hand

cheers,

Signature

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

> Can someone point me to the right direction?
>
> Thanks,
>
> Antonio
MasterChief - 22 Dec 2005 14:35 GMT
using System.Data.SqlClient

should help :-)

> Hi,
>
[quoted text clipped - 28 lines]
> >
> > Antonio
MuZZy - 22 Dec 2005 15:07 GMT
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

> using System.Data.SqlClient
>
[quoted text clipped - 34 lines]
>>>
>>> Antonio

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.