|
-
Jul 3rd, 2003, 10:38 AM
#1
Thread Starter
Member
old fashion!
hi there,
well my problem might sound silly to many of you. When i write in vb 6 i used to write my own connection strings, define my own recordsets,etc... now in vb.net im completly unaware of it. what i need is an exple where u manually connect to a db, select some records to show in a datagrid ,update statement, and delete records from it. is that still possible?
thank you guys in advance, hope didnt sound like a really old grandpa
There is,we are,abou il zoulouf,mijana w mal3ona
-
Jul 3rd, 2003, 11:36 AM
#2
here's a basic example of opening an access database in .net and adding the contents of a table to a DataGrid :
VB Code:
Imports System.Data.OleDb
'///^^^ top of your form's code window.
'////////
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:/bin.mdb"
Dim Command As String = "SELECT * FROM binFrm"
OpenAccessFile(Connection, Command)
End Sub
Private Sub OpenAccessFile(ByVal strConnection As String, ByVal strCommand As String)
Dim objDbConnection As New OleDbConnection(strConnection)
objDbConnection.Open() '///open a new connection.
Dim objCommand As New OleDbCommand(strCommand, objDbConnection)
Dim objAdaptor As OleDbDataAdapter
objAdaptor = New OleDbDataAdapter(objCommand)
Dim objDataSet As New DataSet()
objAdaptor.Fill(objDataSet, "binFrm")
DataGrid1.DataSource = objDataSet.Tables("binFrm") '///fill a datagrid with the recordset
objDbConnection.Close()
objCommand.Dispose()
objAdaptor.Dispose()
objDataSet.Dispose()
End Sub
hope that helps to get you started
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 3rd, 2003, 12:06 PM
#3
Thread Starter
Member
thank you for yr reply! it was really helpfull, but may i ask for one more thing.
str_sql="update tablename set fieldname=1"
how can i write a query like the above to update a certain record in VB .net.
thank you
There is,we are,abou il zoulouf,mijana w mal3ona
-
Jul 3rd, 2003, 12:21 PM
#4
Addicted Member
Originally posted by leghalbon
thank you for yr reply! it was really helpfull, but may i ask for one more thing.
str_sql="update tablename set fieldname=1"
how can i write a query like the above to update a certain record in VB .net.
thank you
str_sql="update tablename set fieldname=1, fieldname2='aa' where id=25"
-
Jul 3rd, 2003, 12:27 PM
#5
Thread Starter
Member
hehehe, oups i did it again, my question turned out wrong.
what i meant was whats the code, i mean how do i define the recorset, how do i excute the update in VB .NET , it's not about the query it self, its about executing an uodate or delete query 
sorry for my honest mistake...
thank you
There is,we are,abou il zoulouf,mijana w mal3ona
-
Jul 3rd, 2003, 02:14 PM
#6
Lively Member
May I recommend ado.net core reference by MS Press ado.net has changed from ado enough, that you basically need to entirely re-educate yourself on the manner.
-
Jul 3rd, 2003, 05:55 PM
#7
Frenzied Member
Originally posted by Iamthewalrus15
May I recommend ado.net core reference by MS Press ado.net has changed from ado enough, that you basically need to entirely re-educate yourself on the manner.
I second that advice. This is a great book, if you want to know the ins and outs of ADO.NET. Another great book is Pragmatic ADO.NET.
-
Jul 3rd, 2003, 06:07 PM
#8
Sleep mode
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|