J
Joon Park via .NET 247
(Type your message here)
--------------------------------
From: Joon Park
Hi I am very new to ASP.NET and database access. Ive triednumerous times however ive beed getting a data type mismatcherror and i am so lost. my page is suppose to display recordsfrom a database using dataset with multiple tables here is thecode below
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Page Language="VB" Debug="true" %>
<html>
<SCRIPT language="VB" runat="server" >
Dim objConnection As OleDbConnection
Dim strConnection As String
Dim objAdapter As OleDbDataAdapter
Dim SelectCmd As String
sub Page_load()
Dim BID As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; DataSource=C:\Inetpub\wwwroot\test\test.mdb"
BID = Request.QueryString("BID")
If Not BID = "" Then
B_ID.Value = Request.QueryString("BID")
GetName_Click()
End IF
End sub
Sub GetName_Click()
SelectCmd = "SELECT B.NAME, ((A.@Pref1 * .6) + (A.@Pref2* .3) + (A.@Pref3 * .1)) AS SCORE FROM SD_CUST_SURVEY AS A,SD_CONTACT_INFO AS B WHERE (A.BUSINESS_ID = B.BUSINESS_ID) ANDA.BUSINESS_ID IN (@BID)ORDER BY ((A.@Pref1 * .6) + (A.@Pref2 *.3) + (A.@Pref3 * .1)) DESC"
objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(SelectCmd,objConnection)
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@BID", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@BID").Value =B_ID.Value
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@Pref1", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@Pref1").Value =P1.Value
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@Pref2", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@Pref2").Value =P2.Value
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@Pref3", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@Pref3").Value =P3.Value
Dim DS As New DataSet()
' fill data set
objAdapter.Fill(DS, "SD_CUST_SURVEY")
' bind to data grid
MyDataGrid.DataSource =DS.Tables("SD_CUST_SURVEY").DefaultView
MyDataGrid.DataBind()
End Sub
</SCRIPT>
HELP!
thanks
--------------------------------
From: Joon Park
Hi I am very new to ASP.NET and database access. Ive triednumerous times however ive beed getting a data type mismatcherror and i am so lost. my page is suppose to display recordsfrom a database using dataset with multiple tables here is thecode below
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Page Language="VB" Debug="true" %>
<html>
<SCRIPT language="VB" runat="server" >
Dim objConnection As OleDbConnection
Dim strConnection As String
Dim objAdapter As OleDbDataAdapter
Dim SelectCmd As String
sub Page_load()
Dim BID As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; DataSource=C:\Inetpub\wwwroot\test\test.mdb"
BID = Request.QueryString("BID")
If Not BID = "" Then
B_ID.Value = Request.QueryString("BID")
GetName_Click()
End IF
End sub
Sub GetName_Click()
SelectCmd = "SELECT B.NAME, ((A.@Pref1 * .6) + (A.@Pref2* .3) + (A.@Pref3 * .1)) AS SCORE FROM SD_CUST_SURVEY AS A,SD_CONTACT_INFO AS B WHERE (A.BUSINESS_ID = B.BUSINESS_ID) ANDA.BUSINESS_ID IN (@BID)ORDER BY ((A.@Pref1 * .6) + (A.@Pref2 *.3) + (A.@Pref3 * .1)) DESC"
objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(SelectCmd,objConnection)
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@BID", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@BID").Value =B_ID.Value
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@Pref1", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@Pref1").Value =P1.Value
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@Pref2", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@Pref2").Value =P2.Value
objAdapter.SelectCommand.Parameters.Add(NewOleDbParameter("@Pref3", OleDbType.Char))
objAdapter.SelectCommand.Parameters("@Pref3").Value =P3.Value
Dim DS As New DataSet()
' fill data set
objAdapter.Fill(DS, "SD_CUST_SURVEY")
' bind to data grid
MyDataGrid.DataSource =DS.Tables("SD_CUST_SURVEY").DefaultView
MyDataGrid.DataBind()
End Sub
</SCRIPT>
HELP!
thanks