Is it possible to make these two programs work together? I make a database in MS Access, and I can use VB. NET to login into the account that is on the database.
Printable View
Is it possible to make these two programs work together? I make a database in MS Access, and I can use VB. NET to login into the account that is on the database.
yes, its possible, you just assign the login in the connection string. You can check out http://www.connectionstrings.com in order to find the string you need... You would then use oledb connection objects and data adapters in order to access it...
EDIT: here's a sample...
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=;"
**i believe you would need the full path to the database in the datasource
Did I miss the release of Access 2004? ;)
Sorry man I meant 2003!
Thanks for the example, but how would I make it so like I have 2 text boxes. Username and Password. A person types in his info and logs in.Quote:
Originally Posted by gigemboy
http://www.homeandlearn.co.uk/NET/nets12p4.html
read up its good stuff :)
you just concat the variables into your connection string...
VB Code:
Dim UserName as String = TextBox1.text Dim PassWord as String = TextBox2.Text Dim StrConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=" & _ [B]UserName[/B] & ";Password=" & [B]PassWord[/B] & ";" 'strconn would be the connection string variable you use in your data adapters...
Ok, so I have a form with textbox1 and textbox2, and a button. When I press the button how do I activate StrConn?Quote:
Originally Posted by gigemboy
You're getting all into the basic matters of using ADO.NET, best to read up on it... but here is a post I had made a few days ago... the strconn would be changed to include the username and password, like my above posts...
_____
Here some sample code from a project I had done, all the objects are created in code, with no objects dragged to the form in designer.. a datagrid1 should be created in order to display the results..
VB Code:
Dim strTable As String = "MyTableName" 'remember, if table has spaces, place it in brackets Dim DBPath as String = "C:\mydatabase.mdb" 'change to your database name Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & DBPath & ";" 'connection string to the msaccess database Dim MyDataSet As New System.Data.DataSet Dim MyAdapter As New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM " & strTable, strConn) 'strconn was the connection string i posted above, strTable is a variable with the table name Dim MyCmdBuilder As New System.Data.OleDb.OleDbCommandBuilder(MyAdapter) 'this is just used if you want to insert or update the database later, not required if you are just viewing the data MyAdapter.Fill(MyDataSet) 'connects to the database, fills dataset with data DataGrid1.DataSource = MyDataSet.Tables(0) 'sets datagrid source to the dataset, displays results DataGrid1.Focus()
Of course, this is without the Try / Catch blocks for errors, so you would eventually put them in, in order to catch errors with the connection, etc