I have been coding without drag dropping.
So I have been recently trying to go the other route and trying to use the
gui editor ( drag drop ).
That is where the initial issue comes to play.
If you drag drop adding a dataset in the databrowser, it adds the connection
string into the Settings Portion of the application.
This Connection string cannot be modified at runtime.
By adding the data_adapter to the toolbar and adding it that way, gives you
the same control as doing it all thru code.
All part of the learning curve I guess,
I just wish the oleDataAdapter would have originally been in the toolbar.
If you search for "changing connection string at runtime" on the net, you
get some crazy solutions. None of which end up doing what I stated below.
Learn something every day i guess.
Miro
"Stephany Young" <noone@localhost> wrote in message
news:(E-Mail Removed)...
> Which is exactly Branco told you in the first place, and also the same way
> as you do it in all flavours of VB.NET (2002), VB.NET 2003 and VB.NET
> (2005).
>
> I think that we couldn't really understand why you couldn't 'get it' from
> the start.
>
> It might be all very well being able to drag-and-drop components on to a
> form, but unless you have an understanding of what is happening 'under the
> hood' then you really make a rod for your own back.
>
> Wizards are really a 'one size - fits all' thing but thaey can only do
> what they are configured to do. If you only know how to use the 'wizards'
> then the moment that you need to do something that the wizard doesn't
> handle then you are in trouble.
>
>
> "Miro" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Ok,
>>
>> For those of you who are interseted...im posting this cause ive spent
>> hours at this, went out and bought an ADO.net book and it was in there.
>>
>> Here is what you do ( vb express 2005 ) to be able to use the objects in
>> the gui environment and a database connection that can be changed at
>> runtime, instead of it being stored in the application settings.
>>
>> Right click on the TooBox Menu, and click on Choose Items
>>
>> Add in the OleDbDataAdapter
>>
>> Create a form
>> Add the OleDBDataAdapter.
>> Click on the little arrow in the top right of the oleDBDataAdapter and
>> "Configure Data Adapter", and also,
>> "Generate DataSet".
>>
>> Create a DataGrid On your Form, and again with the little top right
>> thingy, choose your dataset.
>> -Add your columns
>>
>> Now add a command button, and this code ( change the datasetname )'
>> ===
>> If OleDbConnection1.State = ConnectionState.Open Then
>> OleDbConnection1.Close()
>> MyFirstDataSet1.Clear()
>> Debug.WriteLine("closed")
>> Else
>> OleDbConnection1.Open()
>> Debug.WriteLine("Fill")
>> OleDbDataAdapter1.Fill(MyFirstDataSet1)
>> Debug.WriteLine("Open")
>> End If
>> ====
>>
>>
>> At this point the connection is not stored in teh Settings of the
>> Application, but it is stored on the form object.
>> By this being on the form object, you can add and use the Gui Environment
>> to add and delete columns on the form.
>> You can change your connection path / or whatever at runtime.
>>
>> Great book...Microsoft ADO.Net 2.0 - Step By Step 2005 edition.
>> My 2003 vb.net book just doesnt cut it anymore.
>>
>> I am happy now. Sorry for all the posts.
>>
>> Miro
>>
>>
>>
>>
>> "Miro" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> First off, let me say - Thanks for responding. I have been cracking my
>>> head over this all day on and off.
>>>
>>> I may not be fully understanding everything, but... let me try to
>>> explain a couple things and my theory.
>>>
>>> Here is an example of what I am trying to do ( and to do this without
>>> fully doing it in code so i can drag drop ).
>>>
>>> I have a file layout.
>>> There are multiple files - with the same file layout in different
>>> folders. ( And i mean each have the same tables and fields - just
>>> different data )
>>>
>>> The user double clicks on an option ( basically selects one one of the
>>> files ) and Then I want to "change the connection string", and Open()
>>> the connection.
>>> Now, since the file "layouts" will always be the same I have a file
>>> layout I specify in "Design" mode of my appliction so I can drag drop
>>> items into a datagrid and such. But when the form is running, this db
>>> will either a) not exist or b) is there but is irrelevant - its a blank
>>> db.
>>>
>>> Currently - i do it by "code" and i dim a dataadapter with a
>>> stringVariable as the connection that is open and continue on.
>>>
>>> I must be missing something "big" or I dont see the big picture.
>>> I would assume, the same way a Timer can be added to a from, a
>>> Connection should be able to be added to a form.
>>> This would have a property of "Open" "Close" and a path to the file and
>>> such.
>>> Simillarly an oledbConnection is added, and a dataAdapter.
>>>
>>> So the form Loads...everything is off. You can have a command button
>>> and that command button sets your "Connection" to Open() and then fills
>>> your dataset and off you go.
>>>
>>> Or is that too much dreaming.
>>>
>>> Lets look at a simpler example.
>>> You have Microsoft Word. Microsoft word can save multiple "word"
>>> documents ( or in my case mdb files ). It then can open any "word"
>>> document - from anywhere. It can save / create new / delete ones on the
>>> fly.
>>> That is why it seems silly that it wants to store a "connection string"
>>> and make it read only in the "settings" portion of the application. By
>>> this theory, Microsoft word would need to have hardcoded every possible
>>> document name and location on your harddrive.
>>>
>>> So am I missing something in my "logical thinking" of it being silly?
>>> Im assuming my answer is not to drag drop the tables onto my forms, but
>>> I have to do it all manually as I have started doing behind the sence
>>> inside the code.
>>>
>>> Thanks,
>>>
>>> Miro
>>>
>>>
>>> "Branco Medeiros" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Miro wrote:
>>>> <snip>
>>>>> As I understand it, by not adding a connection thru code, it adds it
>>>>> into
>>>>> the "settings" as a connection string. This is a read only property
>>>>> and
>>>>> this value cannot be changed at runtime.
>>>>>
>>>>> My problem is that I dont know what the path is of the db file /
>>>>> dbfile
>>>>> name/ or even the passsword ( if there is one ) until the program is
>>>>> running and the user clicks a couple things.
>>>>> So how can I have dynamic connection that I can choose to open and
>>>>> close.
>>>>> It seems that the "settings" connectoin gets opened the second the
>>>>> form is
>>>>> opend.
>>>>> I would like to change the connection string and then continue on.
>>>> <snip>
>>>>
>>>> The connection is used by the DataAdapters, and is initially blank.
>>>> Only when the connection is needed for the first time is that the
>>>> DataAdapter loads it from the settings. This usually happens when you
>>>> perform a Fill for the first time.
>>>>
>>>> I didn't try it, but the adapter's code seems to suggest that if you
>>>> assign the connection yourself, the new value will replace the
>>>> original. This must be done for each DataAdapter, and once for each
>>>> live instance of the DataSet (tipically, one per form).
>>>>
>>>> HTH.
>>>>
>>>> Regards,
>>>>
>>>> Branco.
>>>>
>>>
>>>
>>
>>
>
|