Trying to get my head around Using mysql with vb.net. Can someone please help me out with an sql statement. This started out as some downloaded code which I've tried to adapt but seem to mess it up with parameters:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.odbc" %>
<html>
<script language="VB" runat="server">
Sub GetExpenses_Click(Sender As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As odbcConnection
Dim MyCommand As odbcDataAdapter
Dim SelectCommand As String = "select DATE_FORMAT(Date, '%d/%m/%Y %a') as 'Date', Detail, CONCAT('£', Amount) As Cost, Fuel " & _
"from expenses where fuel = ?" ///*** This is my problem ***
MyConnection = New odbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;" & _
"Database=SomeDb;uid=Fred;pwd=Bloggs;Port=3306;Option=3;")
MyCommand = New odbcDataAdapter(SelectCommand, MyConnection)
MyCommand.SelectCommand.Parameters.Add(New odbcParameter(?, odbcDbType.Enum)) ''' and this
MyCommand.SelectCommand.Parameters("?").Value = MySelect.Value
DS = new DataSet()
MyCommand.Fill(DS, "employees")
MyDataGrid.DataSource=DS.Tables("employees").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
<body style="font: 10pt verdana">
<form runat="server">
<h3><font face="Verdana">Parameterized Select to a DataGrid Control</font></h3>
Select a State:
<select id="MySelect" runat="server">
<option>1</option>
<option>0</option>
</select>
<input type="submit" OnServerClick="GetAuthors_Click" Value="Get Authors" runat="server"/><p>
<ASP
ataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</form>
</body>
</html>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.odbc" %>
<html>
<script language="VB" runat="server">
Sub GetExpenses_Click(Sender As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As odbcConnection
Dim MyCommand As odbcDataAdapter
Dim SelectCommand As String = "select DATE_FORMAT(Date, '%d/%m/%Y %a') as 'Date', Detail, CONCAT('£', Amount) As Cost, Fuel " & _
"from expenses where fuel = ?" ///*** This is my problem ***
MyConnection = New odbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;" & _
"Database=SomeDb;uid=Fred;pwd=Bloggs;Port=3306;Option=3;")
MyCommand = New odbcDataAdapter(SelectCommand, MyConnection)
MyCommand.SelectCommand.Parameters.Add(New odbcParameter(?, odbcDbType.Enum)) ''' and this
MyCommand.SelectCommand.Parameters("?").Value = MySelect.Value
DS = new DataSet()
MyCommand.Fill(DS, "employees")
MyDataGrid.DataSource=DS.Tables("employees").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
<body style="font: 10pt verdana">
<form runat="server">
<h3><font face="Verdana">Parameterized Select to a DataGrid Control</font></h3>
Select a State:
<select id="MySelect" runat="server">
<option>1</option>
<option>0</option>
</select>
<input type="submit" OnServerClick="GetAuthors_Click" Value="Get Authors" runat="server"/><p>
<ASP
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</form>
</body>
</html>