开发者

VB.net Query results

I'm a bit confused on how to grab query results. With VBA i would open a record set and have the results of the query written to that recordset. IN VB.net how can I grab the query result and throw each column i开发者_开发百科nto specfic arrays?

dim ssql as string
ssql = " Select * from table "

Now how would I force it to query my DB? I have a connection established already.

After the query how can i play with the columnes and place them into arrays?


This is actually a pretty big topic...you might want to get an overview before you start. http://msdn.microsoft.com/en-us/library/h0y4a0f6(v=vs.80).aspx

To answer your question: If you have a database connection you can use a DataAdapter to fill a local dataTable or dataSet.

connectionString = "Data Source=servername; Initial Catalog=databasename; " + _
    "User ID=userid; Password=password"
cnn = New SqlConnection(connectionString)
cnn.Open()
sqlAdp = New SqlDataAdapter("select * from users", cnn)
sqlAdp.Fill(ds)

EDIT: This is just a sample, you'll want to close the connection and declare a dataSet 'ds'.


You should take a few minutes to read this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜