Shresthaal:
I've run into this several times, as my box is a VFP junky. The problem with creating an ODBC DSN is that when you deploy it, you have to create the DSN on the machine. This is one I use.
(It fills a dataset and then a grid, but you should be able to get the idea.)
=================================
Private Sub ConnectToData()
Try
'Ensure we know which database table we are using
If Opt1.Checked = True Then
DB = Opt1.Text
Else
DB = Opt2.Text
End If
'Create the connection string for the connection
Dim cS As String = "BackgroundFetch=Yes;Collate=Machine;" & _
"Exclusive=No;UID=;SourceType=DBF;Driver=Microsoft Visual FoxPro Driver;" & _
"SourceDB=Y:\INFOSYS\" & DB
'Add the connection
DBCon = New Odbc.OdbcConnection(cS)
'Add the Adapter
DBA = New Odbc.OdbcDataAdapter
'Open the connection
DBCon.Open()
'Declare the SQL String Task
Dim cmdTask As Odbc.OdbcCommand = _
New Odbc.OdbcCommand(txtSQL.Text, DBCon)
cmdTask.CommandType = CommandType.Text
DBA.SelectCommand = cmdTask
'create a dataset
DS = New DataSet("Tasks")
'fill the dataset
DBA.Fill(DS)
'Create a table for the adapter
DBA.TableMappings.Add("Table", "Tasks")
'close the connection
DBCon.Close()
'bind the data to the datagrid
Grid1.SetDataBinding(DS, "Table")
Catch ex As Exception
MessageBox.Show("Check your SQL statement.", "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
===============================
Option buttons contain the names of the database/table.
I hope this helps.
Ron
Ron Repp