컨트롤 ID가 HourlyCharter 인 dropdownList가 있습니다.매개 변수가있는 쿼리를 사용하면 데이터 형식이 일치하지 않습니다. 어떤 아이디어?
그런 다음 코드 숨김에서 hourly가 HourlyCharter 값과 같은 데이터베이스에서 레코드를 쿼리하려고합니다. 그것은 작동
StrSQL = "select h.fare, h.tip, h.total from hourlyQRY h "
StrSQL += " Where h.Hourly = " & HourlyCharter.SelectedValue
' Initialize Database Connection
Dim connStr As String = ConfigurationManager.ConnectionStrings("ALSConnectionString").ConnectionString
Dim conn As New OleDbConnection(connStr)
Dim cmd As New OleDbCommand(StrSQL, conn)
:이 코드를 사용하는 경우
. 나는 이와 같은 매개 변수가있는 쿼리를 사용하는 경우
:
StrSQL = "select h.fare, h.tip, h.total from hourlyQRY h "
StrSQL += " Where h.Hourly = @hourly"
' Initialize Database Connection
Dim connStr As String = ConfigurationManager.ConnectionStrings("ALSConnectionString").ConnectionString
Dim conn As New OleDbConnection(connStr)
Dim cmd As New OleDbCommand(StrSQL, conn)
'We use parametized query to prevent sql injection attack
Dim p1 As New OleDbParameter("@hourly", HourlyCharter.SelectedValue)
cmd.Parameters.Add (P1) 나는 오류 다음 얻을
: 기준 식의
데이터 형식이 일치하지
Hourly는 Number 데이터 형식이며 우리는 Access 2010 데이터베이스를 사용하고 있습니다.
아이디어를 해결하는 방법은 무엇입니까?
'open recordset to receive db values
rs = cmd.ExecuteReader()
' This acts like the (Not RecordSource.Eof) in ASP 3.0 to loop and retrieve records.
While rs.Read()
' If rs("city") <> "" Then
Dim tipValue As Decimal = rs("tip")
Dim totValue = rs("total")
' Else
' End If
Dim tp As String = [String].Format("{0:C}", tipValue)
Dim tot As String = [String].Format("{0:C}", totValue)
lblTip.Text = tp
lblTotal.Text = tot
End While
시도 할 수 있습니다 [문자열]' – OneFineDay