나는 VB.NET을 처음 접하기 때문에 버그가 생길 때 많이 연구한다. 문제는 내가 이것에 대한 해결책을 찾지 못하거나 그것을 원격으로 다루는 것을 찾을 수 없다는 것입니다.@ (at sign) -variables to MySQL
원격 mysql 서버에 연결하고, 쿼리를 실행하고, 데이터 집합으로 돌아 오기위한 소프트웨어를 개발 중입니다. mysql 프롬프트를 통해 서버에 대해이 쿼리를 실행하고 성공적으로 결과를 받았습니다. 하지만 내 애플 리케이션 에서이 쿼리를 실행하려고하면 개체 참조 오류가 발생합니다.
디버깅을 통해 SQL 문자열의 변수에 사용 된 @ 문자가 내 코드에서 문제를 일으키는 것으로 나타 났지만 Visual Studio에서 오류를 발생시키지 않고 서버에이 쿼리를 전달하는 방법을 찾을 수 없습니다. 내가 찾은 변수 사용에 대한 모든 대답은 구체적으로 내 코드에서 변수 값을 규정하고 있음을 시사합니다. 여기
내 코드 내 쿼리의 비트입니다 :Dim mysqlCon As MySqlConnection = New MySqlConnection("Server=" & arrArgs & ";Database=DBNAME;Uid=USER;Pwd=PASS;allow zero datetime=true;")
Dim mysqlString As String = "set @from_scanner = '" & code & "'; set @code='', @altbarcode='', @qty='1', @price='',@Altprice='0', @date_start='',@date_end='',@disc_price='0',@description='', @altdescription=''; set @from_scanner=if(left(@from_scanner,2)='FF',trim(substring(@from_Scanner,3,13)),trim(substring(@from_Scanner,2,13))); select code, altbarcode,description, qty, price into @code, @altbarcode,@altdescription, @qty, @Altprice from altbar where [email protected]_scanner; set @code=if(@code='',@from_Scanner,@code); select disc_price, date_end into @disc_price, @date_end from plu where (code=trim(left(@code,12)) or [email protected]) and current_date between date_start and date_end and disc_price<>price and disc_price<>0; select price, description into @price, @description from plu where code=trim(left(@code,12)) or [email protected]; set @price=if(ifnull(@disc_price,0)=0 or @disc_price='', @price,@disc_price); set @price=if(@qty>1 and @Altprice > 0, @Altprice, @price*@qty); set @description=if(@altdescription<>'', @Altdescription, @description); select @code, format(@price,2) Price, @description,@date_end;"
Dim mysqlCom As MySqlCommand = New MySqlCommand(mysqlstring, mysqlCon)
Dim mysqlAdapter As New MySqlDataAdapter
Dim mysqlData As New DataSet
mysqlCon.Open()
mysqlAdapter.SelectCommand = mysqlCom
mysqlAdapter.Fill(mysqlData, "tblDBData")
그래서 내가 정말 알아야 할 VB에서 문제없이 MySQL의 서버에이 쿼리를 전달하는 방법이다.
빠른 응답을 감사하십시오. – user1041310
내 문제는 내가 서버에 전달하는 유일한 정보는 스캐너의 항목 코드이며 VB 변수 "code"를 통해이 정보를 보냅니다. 쿼리 자체가 모든 작업을 수행하고 데이터베이스에 대해 쿼리를 실행하는 동안 mysql 변수를 할당/재 할당하기 때문에 쿼리에 mysql 변수를 만들었습니다. 이 방법으로 mysql 서버는 모든 작업을 수행하고 VB에 데이터 세트로 단일 레코드를 제공한다. VB에서 변수 값을 설정하고 싶지 않습니다. 변수 컨테이너를 mysql에 전달하고 쿼리에 값을 채우고 싶습니다. – user1041310
나는 지금 무슨 뜻인지 안다. 불행히도, 나는 네가 붙어 있다고 생각한다. 이 경우 코드에서 queryString의 쿼리로 SQL 변수를 실제로 바꾸어야 만한다는 것이 확실합니다. 미안 나는 더 많은 도움이되지 않았다. ( – Jay