Easiest Way To Point To New Database, I Created Data Source And Connection to It, Then Dragged Table

  • Thread starter Thread starter clusardi2k
  • Start date Start date
C

clusardi2k

Hello,

I completed an application as described on the subject line. Now, I
have to delete my DataGridView, re-create the DataSet, TableAdapter,
BindingSource, and BindingNavigator. I have to set all the properties
also that I liked.

What is an easier way to do all this? Do you have a simple simple
simple example for me?

The only way I got everything to work initially was if I used the
Wizard. I have to use the wizard!

So, to point to a new database, I have to do all this because I don't
know how to correctly get everything to work if I don't.

Help,
Christopher Lusardi
 
Search your project for the database name, and that will point you to the
line that you need to change
 
Jeff said:
Search your project for the database name, and that will point you to the
line that you need to change

How do I do this? When I go to the solution explorer and server I see
the path to the database but I can only delete that. I can't change
that! What do I change in the project? Specifically, what are the
button clicks that I need to do to change the database name? I'm lost.

Thanks,
Christopher Lusardi
 
Clusardi,

I thought I wrote this already in a message to you.
Go to the solution explorer, click on the icon show all files, and all code
created by the wizard becomes visible to you.

I hope this helps,

Cor
 
Cor said:
Go to the solution explorer, click on the icon show all files, and all code
created by the wizard becomes visible to you.

Cross my fingers and hope it works, but I have to wait till Monday
before I try again!

Anyway noviceness aside, if I remember right at one point I was able to
use the search feature and it pulled up a lot of code which I ignored.
I then did a control F in my displayed code and was able to find what I
wanted. I'll try again Monday!

Thanks for the answer or I'll have to ask again,
Chris Lusardi

(I'm a traditional program an have to get used to the code given to me
by Visual Basic.)
 
Cor said:
Go to the solution explorer, click on the icon show all files, and all code
created by the wizard becomes visible to you.

What should I do?

I have still been unsuccessful at trying to change the path to the
database, so I have to ask for guidance as a novice. If I give you more
detail it should help you straighten a novice out!

So, when I do as you eloquently said, I do not see any explicit
references to the database in the VB code. But, when I tried doing
"Edit, Find Symbol", I am given a list of things that point to the
database explicitly (I.E.: Some type of expansion of the variable to
the location of the database is being shown). This listing through the
"find symbol" offers the option "goto definition". When I go to the
definition, I see only the variable name and no explicit path to the
database. It's taking me to the code you said I should look at.

Again, my program runs correctly except I have to be able to change the
location of the database on a PC.

Background: I created the connection to the database by clicking on
"Data, Add New Data Source ...", "New Connection button", "Browse" to
the database, save the default connection string, select with checkmark
the table in the database, click "finish" which would produce a file
having suffix ".xsd" in the Solution Explorer. Then, in the Data
Sources window I dragged the table to my form. The form then shows a
navagation bar and the table. The program runs beautifully.

I can change the path to the database but I would have to create a new
data source connection, connection string, and navigation bar etc.

Briefly, when I did as you described in your last post, I see VB code
such as this:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class ...
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()

P.S.: Yes, you did reply to an older thread about this topic, but your
recommendation wasn't useful to me.

....
 
Strange,

Don't you see a file app.config where you can change the connectionstring

Or

Don't you see this part where you can use the code I placed already in (see
for the connectionstrings the links)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'NorthwindDataSet.Employees' table. You can move, or remove it, as needed.
Dim conn As New SqlClient.SqlConnection("MyConnectionstring")
Me.EmployeesTableAdapter.Connection = conn
Me.EmployeesTableAdapter.Fill(Me.NorthwindDataSet.Employees)

End Sub

For the connectionstrings

http://www.connectionstrings.com/

http://www.carlprothman.net/Default.aspx?tabid=81

I hope this helps,

Cor
 
Cor said:
Don't you see a file app.config where you can change the connectionstring

Well, when I go into the application configuration file, modify the
string to point to the new location, and recompile or build result, the
application works. But, if I go to Edit, Find Symbol I still see many
things saying the old path and nothing with the old path.

I'll try your other stuff.

Still looking,
Chris Lusardi
 
Cor said:
Don't you see a file app.config where you can change the connectionstring


Well, when I go into the application configuration file, modify the
string to point to the new location, and recompile or build result, the

application works. But, if I go to Edit, Find Symbol I still see many
things saying the old path and nothing with the new path. Is that
good or bad?

I'll try your other stuff.


Still looking,
Chris Lusardi
 
Cor said:
Don't you see this part where you can use the code I placed already in (see
for the connectionstrings the links)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'NorthwindDataSet.Employees' table. You can move, or remove it, as needed.
Dim conn As New SqlClient.SqlConnection("MyConnectionstring")
Me.EmployeesTableAdapter.Connection = conn
Me.EmployeesTableAdapter.Fill(Me.NorthwindDataSet.Employees)

End Sub

I looked and found nothing pointing explicitly to any database!

This is what I found in the dataset.vb file:

Me._connection.ConnectionString =
Global.Equipment_Database_Program.My.MySettings.Default....DatabaseConnectionString
End Sub

What should I do?

Thanks,
Christopher Lusardi
 
What is the database you want to point to and where is it locoted. Not to
exact please because than everybody can search for it in these newsgroups so
obfuscate the name and the passwords..

Cor
 
Cor said:
What is the database you want to point to and where is it locoted. Not to
exact please because than everybody can search for it in these newsgroups so
obfuscate the name and the passwords..

The Access database that I would like to access is on my desktop
currently, but I want to know how I can change the location it in an
easy way.

To accomplish this, I could just delete the my dataset, binding source,
table adapter, and binding navigator. And, then just create a new data
source and connection to the new location of the database. But, this
would mean that every time I do this I have to change properties such
as color etc. So, I was looking for an easier way to change the
location of the database in my application.

Chris Lusardi



Christopher Lusardi
 
What are you talking about.

Go to the Edit menu, and choose Find (or Find in Files) (as in any Windows
app)

Simply put the string in app or web.config.
 
Cor said:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'NorthwindDataSet.Employees' table. You can move, or remove it, as needed.
Dim conn As New SqlClient.SqlConnection("MyConnectionstring")
Me.EmployeesTableAdapter.Connection = conn
Me.EmployeesTableAdapter.Fill(Me.NorthwindDataSet.Employees)

End Sub

O'kay, I'll try entering a modified version of this routine in my code.

Chris Lusardi
At 2PM CST, I go out of town till Monday!
 
I can add the code to my VB application code without complaints, but
when I do a Edit, Find Symbol, I still see the old reference to the
database and not the new one. Did I put the code in the right place?

At 2PM CST, I go out of town till Monday!

Employee_Database_Form_Load
'...
'TODO: This line of code loads data into the
'NorthwindDataSet.Employees' table. You can move, or remove it,
as needed.
Dim conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='Q:\Yahoo\Employees\Employees Database.mdb'")
Me.EmployeesTableAdapter.Connection = conn

Me.EmployeesTableAdapter.Fill(Me.Equipment_DatabaseDataSet.EMPLOYEES)

Thank you,
Christopher Lusardi
 
Cor said:
Why would you do Find Symbol.

What is the result of what you did?

When I do the find, I would expect to see new stuff and not old.

The program ran perfectly with the change.

Note: When I tried doing "Edit, Find Symbol", I am given a list of
things that
point to the database explicitly (I.E.: Some type of expansion of the
variable to
the location of the database is being shown). This listing through the
"find symbol" offers the option "goto definition". When I go to the
definition, I see only the variable name and no explicit path to the
database. It's taking me to the code you said I should look at.

Two examples that the "Find Symbol" option shows me:
AddEMPLOYEESRow(Employees_Database_Program.EmployeesDataSet.EMPLOYEESRow)(Employees_Database_Program.Employees_DatabaseDataSet.EMPLOYEESDataTable)-C:\Documents
and Settings\chrislusardi\Desktop\EMPLOYEES
DATABASE\Employees_Database_Program\Employees_Databse_Program\Employees_DatabaseDataSet.Designer.vb(411)
no references available for this item


Employees_Database_Form(Employees_Database_Program) - C:\Documents and
Settings\chrislusardi\Desktop\EMPLOYEES
DATABASE\Employees_Database_Program\Employees_Database_Program\Form1.Designer.vb(2,15)
Partial Class Employees_Database_Form -C:\Documents and
Settings\chrislusardi\Desktop\EMPLOYEES
DATABASE\Employees_Database_Program\Employees_Database_Program\Form1.Designer.vb(2,15)
....
 
I forgot to say that my program runs perfectly with the code change
that I describe above but I think it's incorrect per the "find sybol".

Please forgive any typos in my "find" output. I typed it by hand
because I couldn't cut and paste.

Christopher Lusardi
 
Not sure what you are doing. Don't "Find Symbol", just Find In Files, using
the database name.

And what were you searching for?

Jeff
 
Back
Top