Browse with SQL server 2005

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Cartago
Posts: 13
Joined: Sun Dec 28, 2008 12:48 pm

Browse with SQL server 2005

Post by Cartago »

Greetings to all. I was trying to access SQL Server 2005, with the following connection string:

CnAdo := CreateObject("ADODB.Connection")
CnAdo:Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Data Source=CART-1BE1F478D8\SQLEXPRESS;Initial File Name=C:\Archivos de programa\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf")
oCursor := CreateObject("ADODB.Recordset")


But the question is how do I get data from a table of SQL Server 2005 are shown in a browser?
Thank you. ;)
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: Browse with SQL server 2005

Post by luisvasquezcl »

Hi Cartago,

The only solution is to use one you have to upload the data grid.
best regards,

Luis Vasquez
Cartago
Posts: 13
Joined: Sun Dec 28, 2008 12:48 pm

Re: Browse with SQL server 2005

Post by Cartago »

Hi, luisvasquezcl.
Then, save the query in an array and the array is showing the browse/grid?
Many thanks.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Browse with SQL server 2005

Post by mol »

Hi!
Can you put any working example how to browse and update data from MS SQL Server?

Marek
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: Browse with SQL server 2005

Post by luisvasquezcl »

Hi Marek,

#include 'minigui.ch'
#include 'adodb.ch'

Definition of the main window
Procedure Main
Local oConnection := TOleauto():New('ADODB.Connection')
Local oSql := TOleauto():New('ADODB.Recordset')
oConexion:ConnectionString ='Provider=Microsoft.Jet.OLEDB.4.0;'+;
'Data Source=MyTable.mdb;'+;
'User Id=Admin;'+;
"Password=;"
oConexion:Open()

oSql:CursorLocation = adUseClient
oSql:Open( "Select * From Client", oConnection, adOpenDynamic, adLockOptimistic )
if oSql:State = adStateClose
Msgstop('Error open table')
Endif


DEFINE WINDOW form1 .... etc... MAIN On Init LoadData(oSql)
DEFINE GRID grid_1
ROW 0
COL 0
etc....
END GRID
END WINDOW
form1.activate
Return

assuming you have a table name and phone fields have the following functions to load data:

Procedure LoadData( oSql )
form1.grid_1.deleteallitems
do while !oSql:eof()
form1.grid_1.additem( { oSql:fields(0):Value, oSql:Fields(1):Value } )
oSql:MoveNext()
enddo
return

you can change the fields position with fieldsname for example:

form1.grid_1.additem( { oSql:Fields('Name'):Value, oSql:Fields('Phone'):Value } )

I hope you will be useful
regards
Luis Vasquez
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Browse with SQL server 2005

Post by mol »

many thanks Luis.
I will test it if I find some free time.
I need to move my one database to Oracle, and I don't know how to do it...

best regards, Marek
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: Browse with SQL server 2005

Post by luisvasquezcl »

Hi Marek.
on page www.connectionstrings.com exist there is a way to connect to an Oracle or other database.
regards,
Luis Vasquez
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Browse with SQL server 2005

Post by mol »

How to update changed data to database?
Marek
Cartago
Posts: 13
Joined: Sun Dec 28, 2008 12:48 pm

Re: Browse with SQL server 2005

Post by Cartago »

Hello, Marek.
With regard to the connection strings if you want to do it fast, you can use a udl file extension, which works as an assistant. You can also switch to Oracle.

You said how:
http://msdn.microsoft.com/en-us/library ... S.71).aspx

Once you create the connection you want to go back to the txt file, open it and copy the last line, which is the connection string.
Regards.

P.S.: Excuse my poor English.
User avatar
Ismach
Posts: 161
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina

Re: Browse with SQL server 2005

Post by Ismach »

amigos Si quieren conectar ORACLE vean el posting ==> http://www.hmgforum.com/viewtopic.php?f=14&t=4362
Post Reply