brillox
asked on
access database and deploying a software with Visual Studio
Hi Experts...
I am new to programming and VB.NET
I am developing a reservation software based on an access database.
Before to go ahead with the development I have a doubt.
I am using a connection builded with the Visual studio OleDbDataAdapter Wizard for all my forms which look like this..
ACCESS.C:\Documents and Settings\Owner\Desktop\pri vato\UNI YEAR 2\Summer 2005\Reservation
When I will deploy the application with Visual Studio, will the database connection works on the client machine ??
The Access database is in the same folder of the application, but NOT in the appliction folder generated by Visual Studio
Do I ahve to use another kind of connection (e.g relative path) and if so how and where ??
I am new to programming and VB.NET
I am developing a reservation software based on an access database.
Before to go ahead with the development I have a doubt.
I am using a connection builded with the Visual studio OleDbDataAdapter Wizard for all my forms which look like this..
ACCESS.C:\Documents and Settings\Owner\Desktop\pri
When I will deploy the application with Visual Studio, will the database connection works on the client machine ??
The Access database is in the same folder of the application, but NOT in the appliction folder generated by Visual Studio
Do I ahve to use another kind of connection (e.g relative path) and if so how and where ??
ASKER
sorry bob....
where I have to use it and what about the dataAdapter connection that I already have ?
Can you give me ane xample ( for a poor beginner .....) ??
where I have to use it and what about the dataAdapter connection that I already have ?
Can you give me ane xample ( for a poor beginner .....) ??
Where do you define and use the connection string?
Bob
Bob
ASKER
In the OleDbAdapter wizard, not in the form code
basically my doubt is ... when I deploy the application can I embed the.mdb file with Visual Studio deployment wizard for the client with the kind of connection that I have ?
basically my doubt is ... when I deploy the application can I embed the.mdb file with Visual Studio deployment wizard for the client with the kind of connection that I have ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I agree with you, but because now I already statred in the other way ( I am half way from the end) what Ic an do without re-writing all the code ?
Will the wizard give me an option to include the database for the client machine ?
Will the wizard give me an option to include the database for the client machine ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
basically....
if I leave everithing as is now and I run the Visual Studio.Net wizard to deploy an application, this will build the .MSI file that I can export in a CD-rom to install the application on a client PC.
Simply doing this ... will the ACCESS dtabase embedded into the .MSI file ?
if I leave everithing as is now and I run the Visual Studio.Net wizard to deploy an application, this will build the .MSI file that I can export in a CD-rom to install the application on a client PC.
Simply doing this ... will the ACCESS dtabase embedded into the .MSI file ?
No it will not, as far as I know.
I'm pretty sure that you'd have to embed it as a resource, and then extract it through code at startup...
Jake
I'm pretty sure that you'd have to embed it as a resource, and then extract it through code at startup...
Jake
ASKER
So the only solution is the one suggested from you and Bob ?
ASKER
Jake,
You convinced me.. I have been up all night and I realized how bad my project has been built, therefore I am starting all again.
I would appreciate if you could show me how to build a class for all my connection, dataAdapters, selectquery, dataset etc...
I also changed the project path which now is in c:\selfCatering
I think that this also will help when I will deploy the application. However I still do not understand if after doing all this I can just start the deployment wizard withount being worried for the mdb file or if also after that I need to do something particular in order to be sure that when installed on anothe PC, the medb file willbe found from the installed application.
You convinced me.. I have been up all night and I realized how bad my project has been built, therefore I am starting all again.
I would appreciate if you could show me how to build a class for all my connection, dataAdapters, selectquery, dataset etc...
I also changed the project path which now is in c:\selfCatering
I think that this also will help when I will deploy the application. However I still do not understand if after doing all this I can just start the deployment wizard withount being worried for the mdb file or if also after that I need to do something particular in order to be sure that when installed on anothe PC, the medb file willbe found from the installed application.
ASKER
I do not know if I am in the right track...
however I now have ( I am reading with more ATTENTIONa VB.NET book)
a app.config class which is like this
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appsettings>
<add key="provider" value="Microsoft.Jet.OLEDB .4.0" />
<add key="Data Source" value="C:\SelfCatering\bok ing.mdb" />
<add key="Initial Catalog" value="Nothing" />
<add key="User ID" value="Nothing" />
<add key="Password" value="nothing" />
</appsettings>
</configuration>
and a DALBase class which is...
Imports System.Configuration
Imports System.Data.Oledb
Public Class DALBase
Implements IDisposable
'Class Level variables
Public SQL As String
Public Connection As OleDbConnection
Public DataAdapter As OleDbDataAdapter
Public Sub Dispose() Implements System.IDisposable.Dispose
If Not DataAdapter Is Nothing Then
DataAdapter.Dispose()
DataAdapter = Nothing
End If
If Not Connection Is Nothing Then
Connection.Close()
Connection.Dispose()
Connection = Nothing
End If
End Sub
Public Sub OpneConn()
Try
Connection.Open()
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce ptionErr.M essage, _
OleDbExceptionErr.InnerExc eption)
Catch InvalidOperationExceptionE rr As InvalidOperationException
Throw New System.Exception(InvalidOp erationExc eptionErr. Message, _
InvalidOperationExceptionE rr.InnerEx ception)
End Try
End Sub
Public Sub CloseConn()
Connection.Close()
End Sub
End Class
As for the OleDbCommand I prefer to implement in each form when needed
So I assume that if I have a form Form1, with a datagrid to display the proeprty table content from the access database I can then do something like this...
'initialize a new istance of the DALBAse class which should read the connection data from the app.config
objDal = New DALBase
Dim Connection1 As OleDbConnection = New OleDbConnection(objDal)
Dim DataSet1 = As New DataSet()
DataSet1 = New DataSet("Dataset1")
Dim OleDbDataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter
Dim Command1 As OleDbCommand = New OleDbCommand(SELECT * FROM Property")
Command1.CommandType = CommandType.Text
objDal.OpenConn()
Command1.Connection = Connection1
OleDbDataAdapter1.SelectCo mmand = Command1
OleDbDataAdapter1.Fill(Dat aSet1, "property")
I do not want to try it before some of you will let me know about this.....
however I now have ( I am reading with more ATTENTIONa VB.NET book)
a app.config class which is like this
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appsettings>
<add key="provider" value="Microsoft.Jet.OLEDB
<add key="Data Source" value="C:\SelfCatering\bok
<add key="Initial Catalog" value="Nothing" />
<add key="User ID" value="Nothing" />
<add key="Password" value="nothing" />
</appsettings>
</configuration>
and a DALBase class which is...
Imports System.Configuration
Imports System.Data.Oledb
Public Class DALBase
Implements IDisposable
'Class Level variables
Public SQL As String
Public Connection As OleDbConnection
Public DataAdapter As OleDbDataAdapter
Public Sub Dispose() Implements System.IDisposable.Dispose
If Not DataAdapter Is Nothing Then
DataAdapter.Dispose()
DataAdapter = Nothing
End If
If Not Connection Is Nothing Then
Connection.Close()
Connection.Dispose()
Connection = Nothing
End If
End Sub
Public Sub OpneConn()
Try
Connection.Open()
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionErr.InnerExc
Catch InvalidOperationExceptionE
Throw New System.Exception(InvalidOp
InvalidOperationExceptionE
End Try
End Sub
Public Sub CloseConn()
Connection.Close()
End Sub
End Class
As for the OleDbCommand I prefer to implement in each form when needed
So I assume that if I have a form Form1, with a datagrid to display the proeprty table content from the access database I can then do something like this...
'initialize a new istance of the DALBAse class which should read the connection data from the app.config
objDal = New DALBase
Dim Connection1 As OleDbConnection = New OleDbConnection(objDal)
Dim DataSet1 = As New DataSet()
DataSet1 = New DataSet("Dataset1")
Dim OleDbDataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter
Dim Command1 As OleDbCommand = New OleDbCommand(SELECT * FROM Property")
Command1.CommandType = CommandType.Text
objDal.OpenConn()
Command1.Connection = Connection1
OleDbDataAdapter1.SelectCo
OleDbDataAdapter1.Fill(Dat
I do not want to try it before some of you will let me know about this.....
ASKER
If there is an EASY but valid way to do it the above... I am ready for it !!
ASKER
Thinking always to my base problem... deploy the application AND the .mdb file on another PC
ASKER
well I had to try it and IT DOES NOT WORK...
I get an exception error that say:
Cast from type 'DALBase' to type 'STring' is not valid
maybe is this line.... Dim Connection1 As OleDbConnection = New OleDbConnection(objDal)
here is the full code of Form1
Imports System.Configuration
Imports System.Data.Oledb
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DataSet1 As New DataSet
DataSet1 = New DataSet("Dataset1")
Dim objDal = New DALBase
Dim Connection1 As OleDbConnection = New OleDbConnection(objDal)
Dim OleDbDataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter
Dim Command1 As OleDbCommand = New OleDbCommand("SELECT * FROM Properties")
Command1.CommandType = CommandType.Text
objDal.OpenConn()
Command1.Connection = Connection1
OleDbDataAdapter1.SelectCo mmand = Command1
OleDbDataAdapter1.Fill(Dat aSet1, "properties")
End Sub
End Class
I get an exception error that say:
Cast from type 'DALBase' to type 'STring' is not valid
maybe is this line.... Dim Connection1 As OleDbConnection = New OleDbConnection(objDal)
here is the full code of Form1
Imports System.Configuration
Imports System.Data.Oledb
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DataSet1 As New DataSet
DataSet1 = New DataSet("Dataset1")
Dim objDal = New DALBase
Dim Connection1 As OleDbConnection = New OleDbConnection(objDal)
Dim OleDbDataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter
Dim Command1 As OleDbCommand = New OleDbCommand("SELECT * FROM Properties")
Command1.CommandType = CommandType.Text
objDal.OpenConn()
Command1.Connection = Connection1
OleDbDataAdapter1.SelectCo
OleDbDataAdapter1.Fill(Dat
End Sub
End Class
ASKER
I changed the DALBase class and added a New sub... now the Full DALBase class is
Imports System.Configuration
Imports System.Data.Oledb
Public Class DALBase
Implements IDisposable
'Class Level variables
Public SQL As String
Public Connection As OleDbConnection
Public DataAdapter As OleDbDataAdapter
Public Sub Dispose() Implements System.IDisposable.Dispose
If Not DataAdapter Is Nothing Then
DataAdapter.Dispose()
DataAdapter = Nothing
End If
If Not Connection Is Nothing Then
Connection.Close()
Connection.Dispose()
Connection = Nothing
End If
End Sub
Public Sub New()
'Get the connection settings from the application configuration file
Dim ObjAppSettings = ConfigurationSettings.AppS ettings
'Build the SQL connection string and initialize the Connection object
Connection = New OleDbConnection("Provider= " & ObjAppSettings.Item("Provi der") & " ; " & _
"Data Source=" & ObjAppSettings.Item("Data Source") & ";")
ObjAppSettings = Nothing
End Sub
Public Sub OpenConn()
Try
Connection.Open()
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce ptionErr.M essage, _
OleDbExceptionErr.InnerExc eption)
Catch InvalidOperationExceptionE rr As InvalidOperationException
Throw New System.Exception(InvalidOp erationExc eptionErr. Message, _
InvalidOperationExceptionE rr.InnerEx ception)
End Try
End Sub
Public Sub CloseConn()
Connection.Close()
End Sub
End Class
now when I fire the Form1 button event I get this...
Unrecognized configuration section appsettings (C:\SelfCatering\bin\SelfC atering.ex e.config line 3).
HELP ......
Imports System.Configuration
Imports System.Data.Oledb
Public Class DALBase
Implements IDisposable
'Class Level variables
Public SQL As String
Public Connection As OleDbConnection
Public DataAdapter As OleDbDataAdapter
Public Sub Dispose() Implements System.IDisposable.Dispose
If Not DataAdapter Is Nothing Then
DataAdapter.Dispose()
DataAdapter = Nothing
End If
If Not Connection Is Nothing Then
Connection.Close()
Connection.Dispose()
Connection = Nothing
End If
End Sub
Public Sub New()
'Get the connection settings from the application configuration file
Dim ObjAppSettings = ConfigurationSettings.AppS
'Build the SQL connection string and initialize the Connection object
Connection = New OleDbConnection("Provider=
"Data Source=" & ObjAppSettings.Item("Data Source") & ";")
ObjAppSettings = Nothing
End Sub
Public Sub OpenConn()
Try
Connection.Open()
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionErr.InnerExc
Catch InvalidOperationExceptionE
Throw New System.Exception(InvalidOp
InvalidOperationExceptionE
End Try
End Sub
Public Sub CloseConn()
Connection.Close()
End Sub
End Class
now when I fire the Form1 button event I get this...
Unrecognized configuration section appsettings (C:\SelfCatering\bin\SelfC
HELP ......
ASKER
OK...
I get what the error on line 3 of the app.config was...
<appsetting> suppose to be <AppSettings>
I fixed it and now I get again .....
Cast from type 'DALBase' to type 'STring' is not valid
I'll give up !!!!!
I get what the error on line 3 of the app.config was...
<appsetting> suppose to be <AppSettings>
I fixed it and now I get again .....
Cast from type 'DALBase' to type 'STring' is not valid
I'll give up !!!!!
ASKER
I'..ve got the solution..... now it works...
new dalbASE CLASS
Imports System.Configuration
Imports System.Data.Oledb
Public Class DALBase
Implements IDisposable
'Class Level variables
Public SQL As String
Public Connection As OleDbConnection
Public Command As OleDbCommand
Public DataAdapter As OleDbDataAdapter
Public Sub Dispose() Implements System.IDisposable.Dispose
If Not DataAdapter Is Nothing Then
DataAdapter.Dispose()
DataAdapter = Nothing
End If
If Not Connection Is Nothing Then
Connection.Close()
Connection.Dispose()
Connection = Nothing
End If
End Sub
Public Sub New()
'Get the connection settings from the application configuration file
Dim ObjAppSettings = ConfigurationSettings.AppS ettings
'Build the SQL connection string and initialize the Connection object
Connection = New OleDbConnection("Provider= " & ObjAppSettings.Item("Provi der") & " ; " & _
"Data Source=" & ObjAppSettings.Item("Data Source") & ";")
ObjAppSettings = Nothing
End Sub
Public Sub InitializeCommand()
If Command Is Nothing Then
Try
Command = New OleDbCommand(SQL, Connection)
Catch OleDbExceptionerr As OleDbException
Throw New System.Exception(OleDbExce ptionerr.M essage, _
OleDbExceptionerr.InnerExc eption)
End Try
End If
End Sub
Public Sub InitializeDataAdapter()
Try
DataAdapter = New OleDbDataAdapter
DataAdapter.SelectCommand = Command
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce ptionErr.M essage, _
OleDbExceptionErr.InnerExc eption)
End Try
End Sub
Public Sub FillDataSet(ByRef oDataSet As DataSet, ByVal TableName As String)
Try
InitializeCommand()
InitializeDataAdapter()
DataAdapter.Fill(oDataSet, TableName)
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce ptionErr.M essage, _
OleDbExceptionErr.InnerExc eption)
Finally
Command.Dispose()
Command = Nothing
DataAdapter.Dispose()
DataAdapter = Nothing
End Try
End Sub
Public Sub OpenConn()
Try
Connection.Open()
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce ptionErr.M essage, _
OleDbExceptionErr.InnerExc eption)
Catch InvalidOperationExceptionE rr As InvalidOperationException
Throw New System.Exception(InvalidOp erationExc eptionErr. Message, _
InvalidOperationExceptionE rr.InnerEx ception)
End Try
End Sub
Public Sub CloseConn()
Connection.Close()
End Sub
End Class
AND CODE INTO THE BUTTONCLICKEVENT OF FORM1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ObjDal = New DALBase
Dim DsProperties As New DataSet
ObjDal.SQL = "SELECT * FROM properties"
ObjDal.InitializeCommand()
ObjDal.OpenConn()
ObjDal.FillDataSet(DsPrope rties, "Properties")
DataGrid1.SetDataBinding(D sPropertie s, "properties")
ObjDal.CloseConn()
End Sub
it works now.... THEN i ASSUME THAT now also my deployment problem (due to the new DALBase class and the app.config file is solved)
new dalbASE CLASS
Imports System.Configuration
Imports System.Data.Oledb
Public Class DALBase
Implements IDisposable
'Class Level variables
Public SQL As String
Public Connection As OleDbConnection
Public Command As OleDbCommand
Public DataAdapter As OleDbDataAdapter
Public Sub Dispose() Implements System.IDisposable.Dispose
If Not DataAdapter Is Nothing Then
DataAdapter.Dispose()
DataAdapter = Nothing
End If
If Not Connection Is Nothing Then
Connection.Close()
Connection.Dispose()
Connection = Nothing
End If
End Sub
Public Sub New()
'Get the connection settings from the application configuration file
Dim ObjAppSettings = ConfigurationSettings.AppS
'Build the SQL connection string and initialize the Connection object
Connection = New OleDbConnection("Provider=
"Data Source=" & ObjAppSettings.Item("Data Source") & ";")
ObjAppSettings = Nothing
End Sub
Public Sub InitializeCommand()
If Command Is Nothing Then
Try
Command = New OleDbCommand(SQL, Connection)
Catch OleDbExceptionerr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionerr.InnerExc
End Try
End If
End Sub
Public Sub InitializeDataAdapter()
Try
DataAdapter = New OleDbDataAdapter
DataAdapter.SelectCommand = Command
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionErr.InnerExc
End Try
End Sub
Public Sub FillDataSet(ByRef oDataSet As DataSet, ByVal TableName As String)
Try
InitializeCommand()
InitializeDataAdapter()
DataAdapter.Fill(oDataSet,
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionErr.InnerExc
Finally
Command.Dispose()
Command = Nothing
DataAdapter.Dispose()
DataAdapter = Nothing
End Try
End Sub
Public Sub OpenConn()
Try
Connection.Open()
Catch OleDbExceptionErr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionErr.InnerExc
Catch InvalidOperationExceptionE
Throw New System.Exception(InvalidOp
InvalidOperationExceptionE
End Try
End Sub
Public Sub CloseConn()
Connection.Close()
End Sub
End Class
AND CODE INTO THE BUTTONCLICKEVENT OF FORM1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ObjDal = New DALBase
Dim DsProperties As New DataSet
ObjDal.SQL = "SELECT * FROM properties"
ObjDal.InitializeCommand()
ObjDal.OpenConn()
ObjDal.FillDataSet(DsPrope
DataGrid1.SetDataBinding(D
ObjDal.CloseConn()
End Sub
it works now.... THEN i ASSUME THAT now also my deployment problem (due to the new DALBase class and the app.config file is solved)
brillox,
Well done! I'm sorry I didn't reply, but I was in meetings yesterday evening.
Do you need any further help? I'm in today till 500pm ET
Jake
Well done! I'm sorry I didn't reply, but I was in meetings yesterday evening.
Do you need any further help? I'm in today till 500pm ET
Jake
I've never used the Deployment Wizard in .NET,
It looks like it's quite easy to include your mdb. You can probably put conditions that will add a registry key to whereever the installer extracts the mdb file, then use the registry to find the path to the database...
Do you need help with this?
P.S. Thanks for the link; that's a great page!
Jake
It looks like it's quite easy to include your mdb. You can probably put conditions that will add a registry key to whereever the installer extracts the mdb file, then use the registry to find the path to the database...
Do you need help with this?
P.S. Thanks for the link; that's a great page!
Jake
ASKER
Yes Jake072...
I am trying to bind a combobox to a database at run-time like this ......
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DsShowCombo As New DataSet
ObjDal.SQL = "SELECT DISTINCT ProeprtyName FROM Properties"
Try
ObjDal.InitializeCommand()
ObjDal.OpenConn()
ObjDal.InitializeDataAdapt er()
ObjDal.FillDataSet(DsShowC ombo, "Properties")
ComboBox1.DataSource = DsShowCombo
ComboBox1.DisplayMember = "ProeprtyName"
ObjDal.CloseConn()
Catch OleDbExceptionerr As OleDbException
Throw New System.Exception(OleDbExce ptionerr.M essage, _
OleDbExceptionerr.InnerExc eption)
Finally
ObjDal.Dispose()
End Try
End Sub
I do not get error.. but into the combobox I get strange text !!!!
I am trying to bind a combobox to a database at run-time like this ......
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DsShowCombo As New DataSet
ObjDal.SQL = "SELECT DISTINCT ProeprtyName FROM Properties"
Try
ObjDal.InitializeCommand()
ObjDal.OpenConn()
ObjDal.InitializeDataAdapt
ObjDal.FillDataSet(DsShowC
ComboBox1.DataSource = DsShowCombo
ComboBox1.DisplayMember = "ProeprtyName"
ObjDal.CloseConn()
Catch OleDbExceptionerr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionerr.InnerExc
Finally
ObjDal.Dispose()
End Try
End Sub
I do not get error.. but into the combobox I get strange text !!!!
brillox,
Your not assigning a ValueMember... (This is usually done to link ForeignKey's)... Not necessary, but I'm not sure... In your DisplayMember, there is a typo (Is this just typing in the browser, or in your code as well?)
Does it say
DataRow.DataView or something like that for all of the rows in the ComboBox? If so, it's the typo in the DisplayMember assignment. Otherwise, ensure that the data you are trying to show, is indeed in the table...
Jake
Your not assigning a ValueMember... (This is usually done to link ForeignKey's)... Not necessary, but I'm not sure... In your DisplayMember, there is a typo (Is this just typing in the browser, or in your code as well?)
Does it say
DataRow.DataView or something like that for all of the rows in the ComboBox? If so, it's the typo in the DisplayMember assignment. Otherwise, ensure that the data you are trying to show, is indeed in the table...
Jake
ASKER
regarding the typo ProeprtyName, this is a typo that I have also into the data row of Access database......
If I add ComboBox1.ValueMember = "PropertyID" I get a runtime error,
If I comment this out, in the combobox when I run the application I get this...
System.Data.DataViewManage rListItemT ypeDescrip tor
If I add ComboBox1.ValueMember = "PropertyID" I get a runtime error,
If I comment this out, in the combobox when I run the application I get this...
System.Data.DataViewManage
ASKER
Do I have to add a loop for dispalying all the rows in the combobox...
What kind of data does PropertyID store?
You shouldn't have to loop anything...
Jake
You shouldn't have to loop anything...
Jake
ASKER
autonumber
ASKER
I changed the button code like this
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DsShowCombo As New DataSet
Obj.SQL = "SELECT DISTINCT ProeprtyName FROM Properties"
Try
Obj.InitializeCommand()
Obj.OpenConn()
Obj.InitializeDataAdapter( )
Obj.FillDataSet(DsShowComb o, "Properties")
' ComboBox1.DataSource = DsShowCombo
' ComboBox1.DisplayMember = "ProeprtyName"
' CHECK THIS LINE !!!!!!
ComboBox1.DataBindings.Add ("Selected Item", DsShowCombo.Tables("Proper ties"), "ProeprtyName")
Obj.CloseConn()
Catch OleDbExceptionerr As OleDbException
Throw New System.Exception(OleDbExce ptionerr.M essage, _
OleDbExceptionerr.InnerExc eption)
Finally
Obj.Dispose()
End Try
End Sub
AND WHAT i GET IN THE COMBOBOX IS..... ComboBox1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DsShowCombo As New DataSet
Obj.SQL = "SELECT DISTINCT ProeprtyName FROM Properties"
Try
Obj.InitializeCommand()
Obj.OpenConn()
Obj.InitializeDataAdapter(
Obj.FillDataSet(DsShowComb
' ComboBox1.DataSource = DsShowCombo
' ComboBox1.DisplayMember = "ProeprtyName"
' CHECK THIS LINE !!!!!!
ComboBox1.DataBindings.Add
Obj.CloseConn()
Catch OleDbExceptionerr As OleDbException
Throw New System.Exception(OleDbExce
OleDbExceptionerr.InnerExc
Finally
Obj.Dispose()
End Try
End Sub
AND WHAT i GET IN THE COMBOBOX IS..... ComboBox1
ASKER
It could be that the problem is because the InitializeDataAdapter routine of the DALBase create a OleDbDataAdapter always with the same name (DataAdapter) which I already use in this form in the button click eevnt for the dataset ?
I assume that due to the different SQL command I need different dataAdapters
I assume that due to the different SQL command I need different dataAdapters
You can't use .DataBindings.Add with a ComboBox (At least I haven't been able to figure out how to get it to work)...
Try:
With ComboBox1
.DataSource = DsShowCombo.Tables("Proper ties")
.DisplayMember = "ProeprtyName"
.ValueMember = "id" ' Or whatever the Primary Key is.
End With
That should work for you... The Property that you need to override with DataBindings.Add is the name of the Property that the DataBinding Applies to, so in this case, it's DataSource
You can also set the ValueMember to be the same as the DisplayMember if you want,
Jake
Try:
With ComboBox1
.DataSource = DsShowCombo.Tables("Proper
.DisplayMember = "ProeprtyName"
.ValueMember = "id" ' Or whatever the Primary Key is.
End With
That should work for you... The Property that you need to override with DataBindings.Add is the name of the Property that the DataBinding Applies to, so in this case, it's DataSource
You can also set the ValueMember to be the same as the DisplayMember if you want,
Jake
ASKER
adding your code...
With ComboBox1
.DataSource = DsShowCombo.Tables("Proper ties")
.DisplayMember = "ProeprtyName"
.ValueMember = "PropertyID" ' Or whatever the Primary Key is.
End With
I get this....
Could not bind to the new value member.
Parameter Value: value
This start to be a nightmare.... DO you think that I should change (again) the class structure and find an easy way to do this ??
I start to get.... GGGGGRRRRRR
With ComboBox1
.DataSource = DsShowCombo.Tables("Proper
.DisplayMember = "ProeprtyName"
.ValueMember = "PropertyID" ' Or whatever the Primary Key is.
End With
I get this....
Could not bind to the new value member.
Parameter Value: value
This start to be a nightmare.... DO you think that I should change (again) the class structure and find an easy way to do this ??
I start to get.... GGGGGRRRRRR
First, make sure that there are NO other references to the ComboBox1's DisplayMember or ValueMember, if there are, remove them (unless you change the data that is displayed). Next, make sure to remove your DataBindings.Add... Code.
If that still doesn't work, post ALL of the Code for the class... Also; make sure that your Selecting PropertyID from your Data... (SELECT * FROM Properties) should be your Select Command...
The Class Structure does not matter, either you are making an error in your databindings, the column "PropertyID" is not there, misspelt, or not loaded into the DataTable...
Don't worry, some bugs can be tedious... You might want to just post your code, and I can take a look...
Jake
If that still doesn't work, post ALL of the Code for the class... Also; make sure that your Selecting PropertyID from your Data... (SELECT * FROM Properties) should be your Select Command...
The Class Structure does not matter, either you are making an error in your databindings, the column "PropertyID" is not there, misspelt, or not loaded into the DataTable...
Don't worry, some bugs can be tedious... You might want to just post your code, and I can take a look...
Jake
ASKER
I AM AN IDIOT !!!!!! ( SORRY .. A BEGINNER.....)
The error was in my SQL string which was.....
Obj.SQL = "SELECT DISTINCT ProeprtyName FROM Properties"
therefore OBVIOUSLY, the .valuemember was unable to find nothing.....
I changed the SQLs tring in ....
Obj.SQL = "SELECT DISTINCT ProeprtyName, PropertyID FROM Properties"
AND IT WORKS .....
The error was in my SQL string which was.....
Obj.SQL = "SELECT DISTINCT ProeprtyName FROM Properties"
therefore OBVIOUSLY, the .valuemember was unable to find nothing.....
I changed the SQLs tring in ....
Obj.SQL = "SELECT DISTINCT ProeprtyName, PropertyID FROM Properties"
AND IT WORKS .....
ASKER
So I assume that now I should ALWAYS inlcude the Id value in the SQL string careless of what I want to display later on.
ASKER
However Jake072, I'll give to you and bob the points for this because is thanks to both of you if I decided to stop using the wizards and start to UNDERSTAND the code !!
Be in touch.. because I am sure that there will be more and more questions from me. btw.. there is a way here to ask for the help of a particular expert ?
Be in touch.. because I am sure that there will be more and more questions from me. btw.. there is a way here to ask for the help of a particular expert ?
I would :)
Are you satisfied with your original question? I'm sorry I couldn't help too much with the Installer, but perhaps planocz's link and my suggestions for the ConnectionString are sufficient?
Let me know,
Jake
Are you satisfied with your original question? I'm sorry I couldn't help too much with the Installer, but perhaps planocz's link and my suggestions for the ConnectionString are sufficient?
Let me know,
Jake
Regarding asking a specific expert:
https://www.experts-exchange.com/questions/20522626/I-don't-know-how-to-ask-to-a-member-in-EE.html
P.S. I think that planocz deserves some of the points as well, as he pointed out the page for the installer...
Jake
https://www.experts-exchange.com/questions/20522626/I-don't-know-how-to-ask-to-a-member-in-EE.html
P.S. I think that planocz deserves some of the points as well, as he pointed out the page for the installer...
Jake
ASKER
According to the wrox book Vb.NET database, the app.config file will be included into the .msi file created with the deployment wizard, therefore it should be fine ( I Hope)...
but you never answered to my question..
If you are not using the deployment wizard, how you deploy Windows applications... with a third party software or...
I am a bit curious
but you never answered to my question..
If you are not using the deployment wizard, how you deploy Windows applications... with a third party software or...
I am a bit curious
brillox,
Sorry, I didn't realize that you'd asked me how I distribute Applications.
I write highly-custom Data Applications for area Tool and Die shops. Deployment, for me, usually consists of a CD with a Directory that I copy onto Client's Program Files... The programs I make almost always "configure" themseleves to work, and I usually spend a while going over how everything works, so I don't really deploy anything to a mass market...
However, after reading the link from planocz, I've just made a Setup for my latest software, to ease installation (and make it look more professional).
Jake
P.S. What specific expert are you looking for?
Sorry, I didn't realize that you'd asked me how I distribute Applications.
I write highly-custom Data Applications for area Tool and Die shops. Deployment, for me, usually consists of a CD with a Directory that I copy onto Client's Program Files... The programs I make almost always "configure" themseleves to work, and I usually spend a while going over how everything works, so I don't really deploy anything to a mass market...
However, after reading the link from planocz, I've just made a Setup for my latest software, to ease installation (and make it look more professional).
Jake
P.S. What specific expert are you looking for?
ASKER
So in the way that i orginized my application (DALBase class and app.config file), I should be fine now and be sure that when installed the .mdb file will be founded from the application on the client PC...
I am looking for RonaldBiemans and you, because you are the persons taht already know about my application.
As you noticed, my English is NOT perfect (I am italian) and I found difficult to explain everithing again for each new question.
I am looking for RonaldBiemans and you, because you are the persons taht already know about my application.
As you noticed, my English is NOT perfect (I am italian) and I found difficult to explain everithing again for each new question.
ASKER
on top of that I make A LOT of typing mistakes !!!!!
brillox,
No worries, I have no trouble understanding you, and typos happen :)
Jake
No worries, I have no trouble understanding you, and typos happen :)
Jake
Bob