I have a question programmer's...

we know that in Visual Studio...you can open a different kind of database...
like: Access, SQL server or file, Oracle...

is there any reference that you'v know on how to make that kind of program??
i don't know where to start...

VB.NET codes please.....

TIA! ^_^

Recommended Answers

All 5 Replies

If you are looking for the actual connection string to connect to a database you need go no further than:
http://www.connectionstrings.com/

It has ever connection string you will ever need.
In terms of connection to a database and manipulating the data the method can change slightly depending on the database you are connecting to. Most databases require particular drivers and connectors to allow the connection.
Visual Studio includes MS SQL and OLEDB (for MS SQL and any OLEDB driven databases). If you want to use MySql then you will need to download the MySql connector.

This is a pretty gentle introduction to accessing database:
http://www.homeandlearn.co.uk/net/nets12p4.html

If you are looking for the actual connection string to connect to a database you need go no further than:
http://www.connectionstrings.com/

It has ever connection string you will ever need.
In terms of connection to a database and manipulating the data the method can change slightly depending on the database you are connecting to. Most databases require particular drivers and connectors to allow the connection.
Visual Studio includes MS SQL and OLEDB (for MS SQL and any OLEDB driven databases). If you want to use MySql then you will need to download the MySql connector.

This is a pretty gentle introduction to accessing database:
http://www.homeandlearn.co.uk/net/nets12p4.html

that's not what i mean... take a look at this video...
http://www.youtube.com/watch?v=dRsYxyt0MhY&feature=youtu.be

Hello !
i watched this given video . it is very simple i write this code right here so there may be some spelling mistake in it. check this out
dgvTableList---is a grid which will show tables of selected database
dgvAllRecords---it will show all records of the selected table

'first import these 
'--------------------------------------------------------------------
Imports System.Data.OleDb
import system.data.sqlclient

'--------------------------------------------------------------------
'use this code at the connect button .

if combobox.text = "System.Data.OleDb" then 

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&txtserver.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
      Dim cmd As OleDbCommand = New OleDbCommand("Select Name from MSysObjects", con)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        dgvTableList.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
end if
if combobox.text = "system.data.sqlclient" then 

Dim con as new sqlconnection("Data Source="&txtserver.text&";Initial Catalog="&txtdb.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
con.open()
dim da as sqldataadpter("Select name from sys.tables",con)
dim dt as datatable
da.fill(dt)
dgvTableList.datasource = dt
con.close()
end if

'place this code on the double click event of your dgvTableList

if combobox.text = "System.Data.OleDb" then 

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&txtserver.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
      Dim cmd As OleDbCommand = New OleDbCommand("Select * from " & dgvTableList.item(0,dgvTableList.currentrow.index).value.tostring , con)'u can use the name of you column in place of 0 (column index)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        dgvAllRecords.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
end if
if combobox.text = "system.data.sqlclient" then 

Dim con as new sqlconnection("Data Source="&txtserver.text&";Initial Catalog="&txtdb.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
con.open()
dim da as sqldataadpter("Select * from " & dgvTableList.item(0,dgvTableList.currentrow.index).value.tostring ,con)'u can use the name of you column in place of 0 (column index)
dim dt as datatable
da.fill(dt)
dgvAllRecords.datasource = dt
con.close()
end if

try to make some efforts before asking any thing this will help you to learn something .well if this code helps you then mark your thread solved and if you like then vote me up :)

Regards

commented: Thanks to this ^_^ +1

I think Hericles was given the direction.
You need to know how to make connection with databases (MSSQL,MySQL,Oracle,etc). Connectionstring.com provides you how to do it.

Hello !
i watched this given video . it is very simple i write this code right here so there may be some spelling mistake in it. check this out
dgvTableList---is a grid which will show tables of selected database
dgvAllRecords---it will show all records of the selected table

'first import these 
'--------------------------------------------------------------------
Imports System.Data.OleDb
import system.data.sqlclient

'--------------------------------------------------------------------
'use this code at the connect button .

if combobox.text = "System.Data.OleDb" then 

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&txtserver.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
      Dim cmd As OleDbCommand = New OleDbCommand("Select Name from MSysObjects", con)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        dgvTableList.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
end if
if combobox.text = "system.data.sqlclient" then 

Dim con as new sqlconnection("Data Source="&txtserver.text&";Initial Catalog="&txtdb.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
con.open()
dim da as sqldataadpter("Select name from sys.tables",con)
dim dt as datatable
da.fill(dt)
dgvTableList.datasource = dt
con.close()
end if

'place this code on the double click event of your dgvTableList

if combobox.text = "System.Data.OleDb" then 

Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&txtserver.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
      Dim cmd As OleDbCommand = New OleDbCommand("Select * from " & dgvTableList.item(0,dgvTableList.currentrow.index).value.tostring , con)'u can use the name of you column in place of 0 (column index)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "MyTable")
        dgvAllRecords.DataSource = myDataSet.Tables("MyTable").DefaultView
        con.Close()
end if
if combobox.text = "system.data.sqlclient" then 

Dim con as new sqlconnection("Data Source="&txtserver.text&";Initial Catalog="&txtdb.text&";User Id="&txtuserid.text&";Password="&txtpassword.text&";")
con.open()
dim da as sqldataadpter("Select * from " & dgvTableList.item(0,dgvTableList.currentrow.index).value.tostring ,con)'u can use the name of you column in place of 0 (column index)
dim dt as datatable
da.fill(dt)
dgvAllRecords.datasource = dt
con.close()
end if

try to make some efforts before asking any thing this will help you to learn something .well if this code helps you then mark your thread solved and if you like then vote me up :)

Regards

Thanks to this...!! ^_^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.