Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Help!! Convert VB Script to C#


Message #1 by "Douglas S. Tarr" <douglas.tarr@l...> on Fri, 26 Jul 2002 14:05:43
Can someone help me convert this VB script to C# ???  Thank you so much!!

<script language="VB" runat="server">

Sub Page_Load(Sender As Object, E As EventArgs) 
	if not Page.IsPostBack then
		doData()
	end if
End Sub

Sub doQuery(Source as Object, E as EventArgs)
	Dim DS As DataSet
	Dim MyConnection As SqlConnection
	Dim MyCommand As SqlDataAdapter
	Dim strState as string
	strState=state.SelectedItem.Text
	'label1.text="State queried is : " & strState
	Label1.Text="You chose: " + strState 
	
	Dim MySQL as string
	MySQL="select * from Authors where state='" & strState & "'"
	panel1.visible="true"
	label2.text=MySQL
	MyConnection = New SqlConnection
("server=localhost;uid=userid;pwd=pwd;database=pubs;")
	MyCommand = New SqlDataAdapter(MySQL, MyConnection)
	DS = new DataSet()
	MyCommand.Fill(ds, "Authors")
	
	MyDataGrid.DataSource=ds.Tables("Authors").DefaultView
	MyDataGrid.DataBind()	

	
End Sub

Sub doData()
	Dim strConn as string 
="server=localhost;database=pubs;uid=sa;pwd=password" 
	Dim Conn as new SQLconnection(strConn) 
	     
	Dim strSQL as string ="select distinct state from authors"
	Dim Cmd as New SQLCommand(strSQL,Conn) 
	Conn.Open() 
	state.DataSource = Cmd.ExecuteReader() 
	state.DataBind() 	
End Sub
</script>

  Return to Index