Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Controls / July 2008



Tip: Looking for answers? Try searching our database.

execute user defined query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
F.N.Z - 17 Jul 2008 07:03 GMT
Hello,
I have a project in vb.net 2005 and it works with a database in SQL server
2005. in this project I prepared a query builder for user like something in
Access. the user can make the queries that he/she wants, for example he/she
wants all the rows that they "name" field is "John", I can write this query
very easily:
select * from MyTable where name='John'

but the problem is I don't know how can I execute this query in vb.net 2005
and show the result for user?please help me!
ssmagin@activedbsoft.com - 18 Jul 2008 09:04 GMT
> but the problem is I don't know how can I execute this query in vb.net 2005
> and show the result for user?please help me!

Use the following code to run a query and display data in a grid:
Suppose that the queryBuilder1 is your query builder object, and it
has the SQL property, and the dataGridView1 is your DataGridView
object.

Dim connection As New SqlConnection(connectionString)
Dim command As SqlCommand = connection.CreateCommand()

command.CommandTimeout = 30
command.CommandText = queryBuilder1.SQL

Dim adapter As New SqlDataAdapter(cmd)
Dim dataset As New DataSet()

Try
adapter.Fill(dataset, "QueryResult")
dataGridView1.DataSource = dataset.Tables("QueryResult")
Catch ex As Exception
MessageBox.Show(ex.Message, "SQL error")
End Try

> I have a project in vb.net 2005 and it works with a database in SQL server
> 2005. in this project I prepared a  query builder for user like something in
> Access.

BTW, you may have a look at our query building solution, if you
interested in it: http://www.activequerybuilder.com/

Sincerely
Sergey Smagin
Active Database Software
http://www.activedbsoft.com/
 
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



©2008 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.