2011-01-17 5 views
0

테이블 어댑터에 연결 문자열에 변수를 사용하려고합니다. 내가 본 유일한 깨끗한 컷 방법은 다음과 같습니다. 그러나 런타임에 "잘못된 연결 문자열"이 나타납니다. 아마이 일을 할 수 없다고 생각 하나?테이블 어댑터를 사용할 때 연결 문자열이 잘못되었습니다.

Private Sub adaptertest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
'TODO: This line of code loads data into the 'BCPM_DDBODataSet.LTC_FBS' table. You can move, or remove it, as needed. 
LTC_FBSTableAdapter.Connection.ConnectionString = "Provider=TDOLEDB;Data Source=TDDEV;Persist Security Info=True;User ID={0};Password={1};Default Database=bcpm_ddbo;Session Mode=ANSI;" 
Me.LTC_FBSTableAdapter.Fill(Me.BCPM_DDBODataSet.LTC_FBS) 

답변

0

당신은 사용자 이름과 암호를 포함하도록 코드를 수정해야 할보십시오.

업데이트 된 코드 발췌 문장. ConnectionString을에 대한 자세한 내용은

Private Sub adaptertest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
'TODO: This line of code loads data into the 'BCPM_DDBODataSet.LTC_FBS' table. You can move, or remove it, as needed. 

Dim DBConnStr as string = "Provider=TDOLEDB;Data Source=TDDEV;Persist Security Info=True;User ID={0};Password={1};Default Database=bcpm_ddbo;Session Mode=ANSI;" 

'NOTE: Replace the DBUserName and DBPwd with the actual username and pwd to DB. 
DBConnStr = String.Format(DBConnStr,"DBUserName","DBPwd") 

LTC_FBSTableAdapter.Connection.ConnectionString = DBConnStr 
Me.LTC_FBSTableAdapter.Fill(Me.BCPM_DDBODataSet.LTC_FBS) 

, 참조는 ConnectionStrings.com

+0

난 그냥 위의 예제를 시도하고 라인에 동일한 오류가 발생했습니다 : LTC_FBSTableAdapter.Connection.ConnectionString = DBConnStr 이것은 확실히 작동해야합니다 ... 내 app.config 파일에 정의 된 연결 문자열이 있지만이 무시하지 않습니다 그? 또한 - 연결 문자열이 정확하고 손으로 코딩 된 업데이트/삽입 쿼리를 수행 할 때 올바르게 작동합니다. – gfuller40

+0

이것은 테라 데이타 백엔드입니다 ... 차이가 있는지 확실하지 않습니다. – gfuller40

+0

TD 연결 문자열을 수정하여 테이블 어댑터와 함께 작동하는 표준 SQL처럼 보이게해야합니다 .... – gfuller40

1

사용자 이름과 암호 값이 제공되지 않아 연결 문자열이 유효하지 않습니다.

LTC_FBSTableAdapter.Connection.ConnectionString = string.format("Provider=TDOLEDB;Data Source=TDDEV;Persist Security Info=True;User ID={0};Password={1};Default Database=bcpm_ddbo;Session Mode=ANSI;" _ 
,TheActualUserName _ 
,TheActualPassword) 
+0

난 내가 결국 할 변수로 원하는 여전히 ... 사용자 ID = diw07을 같은 오류 메시지가 나타납니다 실제 사용자/패스 시도, 비밀번호 = 하키 4; – gfuller40

관련 문제