Hello Guys,
I'm using eVB 3.0 and backend MS MSQL, does anyone know the right connectionstring of MS SQL so I can connect to the server using ADOCE 3.1? Thanks
Printable View
Hello Guys,
I'm using eVB 3.0 and backend MS MSQL, does anyone know the right connectionstring of MS SQL so I can connect to the server using ADOCE 3.1? Thanks
For eMbedded Visual Basic 3.0 MS SQL I not tested becouse I don't use MSSQL, but connection I think no differents from VB6 and it can work, maybe not?:]Quote:
Originally Posted by gilkaths
Tray it:
VB Code:
' eMbedded Visual Basic 3.0 Option Explicit Private oConn As ADOCE.Connection Private Sub cmdTest_Click() 'ODBC Driver for SQL Server 'For Standard Security oConn.Open "Driver={SQL Server};" & _ "Server=MyServerName;" & _ "Database=myDatabaseName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" 'For Trusted Connection security oConn.Open "Driver={SQL Server};" & _ "Server=MyServerName;" & _ "Database=myDatabaseName;" & _ "Uid=;" & _ "Pwd=" ' Or oConn.Open "Driver={SQL Server};" & _ "Server=MyServerName;" & _ "Database=myDatabaseName;" & _ "Trusted_Connection=yes" 'To Prompt user for username and password oConn.Properties("Prompt") = adPromptAlways oConn.Open "Driver={SQL Server};" & _ "Server=MyServerName;" & _ "DataBase=myDatabaseName" 'To connect to SQL Server running on the same computer oConn.Open "Driver={SQL Server};" & _ "Server=(local);" & _ "Database=myDatabaseName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" 'To connect to SQL Server running on a remote computer (via an IP address) oConn.Open "Driver={SQL Server};" & _ "Server=xxx.xxx.xxx.xxx;" & _ "Address=xxx.xxx.xxx.xxx,1433;" & _ "Network=DBMSSOCN;" & _ "Database=myDatabaseName;" & _ "Uid=myUsername;" & _ "Pwd=myPassword" 'Where: '- xxx.xxx.xxx.xxx is an IP address '- 1433 is the default port number for SQL Server. '- "Network=DBMSSOCN" tells ODBC to use TCP/IP rather than Named ' Pipes (Q238949) End Sub Private Sub Form_OKClick() App.End End Sub
Thanks for the info. But I tried your examples, an error occured. "The specified table does not exist", but I double check the server, I have that kind of table. I'll post the code I made. A simple code to connect to MS SQL server using eVB 3.0.
Option Explicit
Private Sub Form_Load()
Dim rs As ADOCE.Recordset
Dim constr As String
Dim i As Integer
Set cn = CreateObject("adoce.connection.3.1")
Set rs = CreateObject("adoce.recordset.3.1")
constr = "Driver={SQL Server};Server=testServer;Database=Testing;Uid=try;Pwd=test"
i = 1
mainGrid.Rows = 1
rs.Open "select * from product", constr
If Not rs.EOF Then
rs.MoveFirst
Do While Not rs.EOF
mainGrid.TextMatrix(i, 0) = rs(0)
mainGrid.TextMatrix(i, 1) = rs(1)
mainGrid.Rows = mainGrid.Rows + 1
i = i + 1
rs.MoveNext
Loop
End If
rs.Close
End Sub
Private Sub Form_OKClick()
App.End
End Sub