Need to bind data from SQL server 2000 to textboxes and also be updated when other users cha

I'm trying to move away from working in microsoft access and try and work with SQL Server. I'm going to be storing around 50K records of data in a table within SQL server at first. I tried using the visual studio.net Dataset control to create all my bound fields in the set, but what I noticed is the connection is not continually connected to the source.

I will have several users using this app, and each could be updating any record at any time, and I need and update to take affect on the server right away and the next time someones accesses that record will see the update. What I have found out is that the DataSet created is only a copy of the Data at that moment and then the connection is closed, so no telling if anything was updated. Now I tried making an ADO connection that is always connected and display the recordset in bound textboxes.

I can connect and create the recordset, but how do I bind the columns to the textboxes and make sure they are updated at the source when a change is made. Below is the sample of how I'm connecting, please any help or new ideas would be greatly appreciated. msgboxes at the bottom was for me to make sure I'm making the connection and seeing all the records.

Dim ObjConnAsNew ADODB.Connection

Dim ObjRSAsNew ADODB.Recordset

Dim countrrAsInteger

Dim strRequestAsString

With ObjConn

.ConnectionTimeout = 30

.CommandTimeout = 30

.Provider ="SQLOLEDB"

.ConnectionString ="Driver={SQL Native Client};Server=DV8110US\TEST;Database=ALSQL;UID=AL;PWD=al;"

EndWith

ObjConn.Open()

strRequest ="SELECT * FROM dbo.DeskGroupings"

ObjRS.Open(strRequest, ObjConn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly)

DoWhileNot ObjRS.EOF

countrr = countrr + 1

ObjRS.MoveNext()

Loop

MsgBox(countrr)

MsgBox(ObjRS.RecordCount)

[3251 byte] By [mike11d11] at [2007-12-25]
# 1
The changes are not made to the original sql database unless you tell it to save. It looks like you're trying to count the records. I have some applications like this with multi users. You can either use the navigator to save it, or use sql update / insert to do it. Either way, the database needs to be told when you are saving your data. For what I do/need, I personally like to use the sql command to link straight than using the tableadapter/dataset/navigator.
gudel at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

dear gudel

i was reading your answer to the above question which is similar to mine, cold you explain how the datbase works in terms of taking data in textboxes and putting them in my database,i have a datagrid if that helps, i know this might be difficult but keep it simple an i am a novice at this, once i understand what vb is doing them i can follow it.

thanks

chaza at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3
After I have my recordset, how would I bind say "Account" field from the "DeskGroupings" table to the Textbox1 control on my form? Also is this going to keep my connection open so I can see when another user has made changes to other records in this table?
mike11d11 at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4

I like dragging the dataset to the form because it's the easiest, it'll have all controls there, then you can remove the ones you don't want, leaving only the textbox. This will not keep the connection open, for you to see the changes your users made, users need to do something to it first before you can see it.

Or you can just have one text box, click on the control, and set the data binding to that account field.


Also, if you just want to know the count, this is probably easier:

Dim Counter As Int32
Using DatabaseConnection As New SqlConnection("Data Source=yourSQLServer;User ID=yourUserID")
DatabaseConnection.Open()

Using Command As New SqlCommand("SELECT * FROM DeskGroupings", DatabaseConnection)
Counter = CInt(Command.ExecuteScalar)
End Using

End Using
Msgbox(Counter)

gudel at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...