CRIAR ODBC SETANDO PORTA

EXPOLETA 04/10/2010 17:34:15
#354390
olá pessoal,peguei esse fonte aki no vb mania http://www.vbmania.com.br/pages/index.php?varModulo=Detalhe&varID=5499
desde ja agradeço.
XXXANGELSXXX 29/12/2010 08:08:23
#360591
Const ODBC_ADD_SYS_DSN = 4
[ô]Setando API
Private Declare Function SQLConfigDataSource Lib [Ô]ODBCCP32.DLL[Ô] (ByVal _
hwndParent As Long, ByVal fRequest As Long, ByVal _
lpszDriver As String, ByVal lpszAttributes As String) As Long

Private Sub CriarDSN_MySQL()
Dim ret%, Driver$, Valores$
Driver = [Ô]MySQL ODBC 5.1 Driver[Ô]
Valores= [Ô]DSN=[Ô] & [Ô]MyDSNCRM[Ô] & Chr(0)
Valores= Valores& [Ô]Server=[Ô] & SERVIDOR.Text & Chr(0)
Valores= Valores& [Ô]Database=[Ô] & BDADOS.Text & Chr(0)
Valores= Valores& [Ô]Description=TechSize CRM.DSN Driver MySql[Ô] & Chr(0)
Valores= Valores& [Ô]UID=[Ô] & USUARIO.Text & Chr(0)
Valores= Valores& [Ô]Port=[Ô] & PORTA.Text & Chr(0)
Valores= Valores& [Ô]Password=[Ô] & SENHA.Text & Chr(0)
ret = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, Driver, Attributes)
If ret <> 1 Then
msg1.MsgBox [Ô] Não foi possível criar a DSN[Ô], vbExclamation, [Ô]Aviso[Ô]
End If
End Sub
EXPOLETA 06/01/2011 15:10:39
#361390
cara,n funionou esse teu script ae.
XXXANGELSXXX 06/01/2011 20:06:56
#361462
  

Const ODBC_ADD_SYS_DSN = 4
Const ODBC_CONFIG_SYS_DSN = 5
Const ODBC_REMOVE_SYS_DSN = 6

Private Declare Function SQLConfigDataSource Lib [Ô]ODBCCP32.DLL[Ô] (ByVal _
hwndParent As Long, ByVal fRequest As Long, ByVal _
lpszDriver As String, ByVal lpszAttributes As String) As Long


Private Sub Build_SystemDSN_MySQL()
Dim ret%, Driver$, Attributes$
Driver = [Ô]MySQL ODBC 5.1 Driver[Ô]
Attributes = [Ô]DSN=[Ô] & [Ô]MyDSNCRM[Ô] & Chr(0)
Attributes = Attributes & [Ô]Server=[Ô] & SERVIDOR.Text & Chr(0)
Attributes = Attributes & [Ô]Database=[Ô] & BDADOS.Text & Chr(0)
Attributes = Attributes & [Ô]Description=TechSize CRM.DSN Driver MySql[Ô] & Chr(0)
Attributes = Attributes & [Ô]UID=[Ô] & USUARIO.Text & Chr(0)
Attributes = Attributes & [Ô]Port=[Ô] & PORTA.Text & Chr(0)
Attributes = Attributes & [Ô]Password=[Ô] & SENHA.Text & Chr(0)
ret = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, Driver, Attributes)
If ret <> 1 Then
MsgBox [Ô] Não foi possível criar a DSN[Ô], vbExclamation, [Ô]Aviso[Ô]
End If
End Sub


veja so esses campos.. USARIO.TEXT, SENHA.TEXT, SERVIDOR.TEXT sao campos texto que tenho no formulario, e funciona sim.. 10000000% eu utilizo eles para criar minhas dsn(s)
KERPLUNK 07/01/2011 10:08:14
#361509
Não é necessário criar uma DSN para usar o MySQL, aliás para banco nenhum. A connection string para banco MySQL, especificando a porta é:
Server=Endereco_do_servidor;Port=[txt-color=#e80000]Porta[/txt-color];Database=Schema;Uid=usuario;Pwd=Senha;

Em vermelho está o parâmetro onde se especifica a porta
Tópico encerrado , respostas não são mais permitidas