Question c# to vb

just369

Member
Joined
May 12, 2010
Messages
17
Programming Experience
Beginner
how can i write tis into vb net...

i know its a script but can i transcribe it into vb net for it to work?

VB.NET:
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>

<script runat="server">
private DataSet CreateDataSource(){
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C://Org.xls; Jet OLEDB:Engine Type=5;"+
"Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
OleDbDataAdapter myCommand = new OleDbDataAdapter( " SELECT * FROM [Chart1$] ", strConn);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet);
return myDataSet;
}

void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack) {
mygrid.DataSource = CreateDataSource();
mygrid.DataBind();
} 
}

void GetValues_Click(Object sender, EventArgs e)
{
String Result="";
foreach(DataGridItem dataGridItem in mygrid.Items)
{

String name= dataGridItem.Cells[0].Text;
Result += name;
Result+=" ";
ResultField.Text=Result;
}
}

</script>
<center>
<form runat="server" method="Post" >

<asp:datagrid runat="server" AutoGenerateColumns="false" width="800" id="mygrid">
<HeaderStyle BorderColor="White" BackColor="black" ForeColor="White" Font-Bold="True" 
Font-Name="Arial" Font-Size="9" HorizontalAlign="Center" />
<ItemStyle BorderColor="" BackColor="#FFFFF0" ForeColor="Black" Font-Name="Arial" 
Font-Size="8" Font-Bold="False" HorizontalAlign="Center" />
<Columns>

<asp:BoundColumn HeaderText="First Name" DataField="Name" />
<asp:BoundColumn HeaderText="Position" DataField="Position" />
</Columns>
</asp:datagrid>
<br>
<br />
<asp:Button id="GetValues" onclick="GetValues_Click" runat="server" 
Text="GetValues"></asp:Button>
<br />
<asp:Label id="ResultField" runat="server" Font-Names="Verdana" 
Font-Size="X-Small"></asp:Label>
</center>
</form>
 
Back
Top