Binding to dynamic sql

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a desktop db background and am new to sql server. How can I bind my
winform controls to a dynamic sql running on sql server backend db? The
reason I need dynamic sql is to give users maximum flexibility on ORDER BY
and WHERE clauses of the sql.

Many Thanks

Regards
 
John,

In code, but as the designer does it for different controls different you
have to do it as well different, there are four types.

Labels, Textboxes, DateTime and more of those once box controls with that
you use in the control the property databindings
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.databindings.aspx

For the Listbox, the Combobox, the DataGridView and the Datagrid it is
the datasource while those are for the first two different from the latter
two.

But that is easy to find.

Cor
 
Hi John,

Your problems can be divided into two parts.
1. dynamic sql. you should really check out docs on ado.net (or perhaps Linq
to SQL, Entity Framework...) and understand that it uses a disconnected
approach - load data in memory, modify it, send back to server. You can't
bind controls directly to server. Dynamic SQLs aren't hard to execute, just
watch out for sql injection.
2. binding. If you create a strong typed dataset in your project the binding
is pretty much trivial - just drop the dataset instance on the form and do
the binding.

You should search for the terms above in the help files...

HTH,
 
Cor & Miha

Many thanks. Pretty familiar with binding/datasets in MS Access environment.
Trying to move to sql server back end. What I am wondering is how to cerate
and pass the dynamic sql to sql server in the first place and then grab back
the resultset from sql server which I can use for binding? Sorry if its a
dumb question, really first time trying to do this with sql server.

Many Thanks

Regards
 
Hi John,

John said:
Cor & Miha

Many thanks. Pretty familiar with binding/datasets in MS Access
environment.

That is something completly different.
Trying to move to sql server back end. What I am wondering is how to
cerate and pass the dynamic sql to sql server in the first place and then
grab back the resultset from sql server which I can use for binding? Sorry
if its a dumb question, really first time trying to do this with sql
server.

It is not a dumb question but rather a beginner's one. There is a ton of
resource online, such as this one:
http://asp.dotnetheaven.com/howto/doc/adoplus/GetDataFromDB.aspx
Basically you have to learn ado.net. A good starting point is reading .net
documentation as well as it explains the basics pretty well.

HTH,
 
Miha, I meant I have used ado.net with access as backend. Now moving to sql
server, just wondering how dynamic sql can be used with sql server as
backend. Do any of the sql server features help in the original requirement
I posted?

Many Thanks

Regards
 
John,

What you know from OleDB and Access is almost the same for SQLClient.SQL.

This is by instance about databinding

The main difference is that there is for SQL more and that you will use in
SQL probably more related tables.

With those related tables there starts the pain

But in my idea, simple start, to begin there is not much more different then
that the ? is in SQL a named parameter, but handled in the same way, and
those named parameters works in SQL easier then in OleDB.

Cor
..
 
No simply try it with an SQL Express or compact database, create in that
your table and change by edit quick-change everywhere OleDB.OleDB in
SQLClient.Sql although you can even use that OleDB.OleDB on an Sql server,
but that is inefficient.

Don't forget to change the connection string and more things like that to
the SQL express database.

Cor
 
Hi

I have a desktop db background and am new to sql server. How can I bind my
winform controls to a dynamic sql running on sql server backend db? The
reason I need dynamic sql is to give users maximum flexibility on ORDER BY
and WHERE clauses of the sql.

Many Thanks

Regards

I would recommend you to read Erland's article
http://www.sommarskog.se/dynamic_sql.html
of Dynamic SQL , before you proceed to the same.
 
Screenivas,

Much words does not mean better.

John is so long a visitor from this newsgroup that he has already seen all
warnings what can go wrong.


Cor
 
Back
Top