Hi again.
This time I'm writing down a simple code block. For a vb.net developer I embed those steps mostly to a dll file and never deal with those codes for about 4-5 years. Now I can't carry my dll to this job. So When I need to connect to a database I open my dll source codes and look for how I did it in the past.
It's again nothing new but keeping them around may be handy. This is a SqlClient type of connection but if you want to connect thru OleDB then you should change SqlClient stuff to OleDb stuff.
You should change red words with yours before you use, I painted connection object to blue to show where you should use
Dim Conn As New Data.SqlClient.SqlConnection("Password=DBPassword;User ID=DBUser;Initial Catalog=DatabaseName;Data Source=DBServerAddress;")
Dim DA As New Data.SqlClient.SqlDataAdapter
Dim DS As New Data.DataSet
Conn.Open()
DA.SelectCommand = New Data.SqlClient.SqlCommand("SELECT * FROM MyTable')", Conn)
DA.Fill(DS, "JustGiveAName")
Do something, do something
Do something, do something
Do something, do something
Do something, do something
DA = Nothing
Conn = Nothing
No comments:
Post a Comment