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 » Sun Dec 28, 2008 12:59 pm

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: 1117
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 13 times
Been thanked: 14 times
Contact:

Post by luisvasquezcl » Sun Dec 28, 2008 6:02 pm

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

Post by Cartago » Sun Dec 28, 2008 7:12 pm

Hi, luisvasquezcl.
Then, save the query in an array and the array is showing the browse/grid?
Many thanks.

User avatar
mol
Posts: 3070
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 180 times
Been thanked: 96 times
Contact:

Post by mol » Fri Jan 09, 2009 9:15 am

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

Marek

User avatar
luisvasquezcl
Posts: 1117
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 13 times
Been thanked: 14 times
Contact:

Post by luisvasquezcl » Tue Jan 13, 2009 8:07 pm

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: 3070
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 180 times
Been thanked: 96 times
Contact:

Post by mol » Tue Jan 13, 2009 8:52 pm

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: 1117
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Has thanked: 13 times
Been thanked: 14 times
Contact:

Post by luisvasquezcl » Wed Jan 14, 2009 8:02 pm

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: 3070
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 180 times
Been thanked: 96 times
Contact:

Post by mol » Thu Jan 15, 2009 8:29 am

How to update changed data to database?
Marek

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

Post by Cartago » Mon Jan 26, 2009 12:40 pm

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: 79
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina
Been thanked: 7 times

Post by Ismach » Wed Nov 14, 2018 1:24 am

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

Post Reply