.net คำสั่งโค๊ด C# ต่อไปนี้ ถ้าเป็น vb.net จะเป็นแบบไหนครับ
คำสั่งนี้ ถ้าแปลงเป็น vb.net จะเป็นแบบไหนครับ ลองแปลงในเว็บก็ไม่ได้ครับ
private void Form1_Load(object sender, EventArgs e) { string ConnectionString = GetConnectionString(); myConnection = new OleDbConnection(ConnectionString); myConnection.Open(); string SqlString1 = "Select * from Orders"; string SqlString2 = "Select * from OrderDetails"; myCommand = myConnection.CreateCommand(); myCommand.CommandType = CommandType.Text; myCommand.CommandText = SqlString1; myDataAdapter = new OleDbDataAdapter(); myDataAdapter.SelectCommand = myCommand; myDataSet = new DataSet(); myDataAdapter.Fill(myDataSet, "Orders"); myCommand.CommandText = SqlString2; myDataAdapter.Fill(myDataSet, "OrderDetails"); }
private void Form1_Load(object sender, EventArgs e) { . . . myDataAdapter.Fill(myDataSet, "Orders"); myCommand.CommandText = SqlString2 myDataAdapter.Fill(myDataSet, "OrderDetails"); // ---- สร้าง relation ----- DataRelation myDataRelation = new DataRelation("Order_OrderDetails", myDataSet.Tables["Orders"].Columns["OrderID"], myDataSet.Tables["OrderDetails"].Columns["OrderID"]); //------------------------ orders_BindingSource = new BindingSource(); ordersDetail_BindingSource = new BindingSource(); // --กำหนด DataSource ให้กับ Bindingsource orders_BindingSource.DataSource = myDataSet; orders_BindingSource.DataMember = "Orders"; ordersDetail_BindingSource.DataSource = orders_BindingSource; ordersDetail_BindingSource.DataMember = "Order_OrderDetails"; // --Binding ให้กับ Datagridview ทั้งสอง dgvOrders.DataSource = orders_BindingSource; dgvOrderDetails.DataSource = ordersDetail_BindingSource; }Tag : .NET, VB.NET, Windows
Date :
2012-12-07 02:33:05
By :
pai
View :
1219
Reply :
7
google ช่วยคุณได้ ค้นหาคำว่า convert c# to vb.net
Date :
2012-12-07 09:10:51
By :
tee
ทำไม code ถึงเป็นแบบนั้นครับ
Date :
2012-12-07 09:16:54
By :
mr.win
ผมลองcopy ไปconvertในเว็บที่ คุณ tee แนะนำ แต่มัน convert เป็น vb ไม่ได้ครับ ผมเลยเอามาถามท่านผู้รู้ในนี้ครับ
Date :
2012-12-09 01:38:26
By :
naipee
จัดเรียง Code ให้มันถูกต้อง แล้วเอามาโพสหน่อยครับ
Date :
2012-12-09 08:14:55
By :
mr.win
convert ได้ครับ เอาไปวางที่ละ method สิครับ
Date :
2012-12-09 12:08:06
By :
yo
Code (C#)
private void Form1_Load(object sender, EventArgs e) {
string ConnectionString = GetConnectionString();
myConnection = new OleDbConnection(ConnectionString);
myConnection.Open();
string SqlString1 = "Select * from Orders";
string SqlString2 = "Select * from OrderDetails";
myCommand = myConnection.CreateCommand();
myCommand.CommandType = CommandType.Text;
myCommand.CommandText = SqlString1;
myDataAdapter = new OleDbDataAdapter();
myDataAdapter.SelectCommand = myCommand;
myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "Orders");
myCommand.CommandText = SqlString2;
myDataAdapter.Fill(myDataSet, "OrderDetails");
}
private void Form1_Load(object sender, EventArgs e) {
myDataAdapter.Fill(myDataSet, "Orders");
myCommand.CommandText = SqlString2
myDataAdapter.Fill(myDataSet, "OrderDetails");
// ---- สร้าง relation -----
DataRelation myDataRelation = new DataRelation("Order_OrderDetails", myDataSet.Tables["Orders"].Columns["OrderID"], myDataSet.Tables["OrderDetails"].Columns["OrderID"]);
//------------------------
orders_BindingSource = new BindingSource();
ordersDetail_BindingSource = new BindingSource();
// --กำหนด DataSource ให้กับ Bindingsource
orders_BindingSource.DataSource = myDataSet;
orders_BindingSource.DataMember = "Orders";
ordersDetail_BindingSource.DataSource = orders_BindingSource;
ordersDetail_BindingSource.DataMember = "Order_OrderDetails";
// --Binding ให้กับ Datagridview ทั้งสอง
dgvOrders.DataSource = orders_BindingSource;
dgvOrderDetails.DataSource = ordersDetail_BindingSource;
}
Date :
2012-12-09 13:34:10
By :
Guest
ผมว่า Form_Load ต้องมีอันเดียวครับ
Code (VB.NET)
Private Sub Form1_Load(sender As Object, e As EventArgs)
Dim ConnectionString As String = GetConnectionString()
myConnection = New OleDbConnection(ConnectionString)
myConnection.Open()
Dim SqlString1 As String = "Select * from Orders"
Dim SqlString2 As String = "Select * from OrderDetails"
myCommand = myConnection.CreateCommand()
myCommand.CommandType = CommandType.Text
myCommand.CommandText = SqlString1
myDataAdapter = New OleDbDataAdapter()
myDataAdapter.SelectCommand = myCommand
myDataSet = New DataSet()
myDataAdapter.Fill(myDataSet, "Orders")
myCommand.CommandText = SqlString2
myDataAdapter.Fill(myDataSet, "OrderDetails")
Dim myDataRelation As New DataRelation("Order_OrderDetails", myDataSet.Tables("Orders").Columns("OrderID"), myDataSet.Tables("OrderDetails").Columns("OrderID"))
orders_BindingSource = New BindingSource()
ordersDetail_BindingSource = New BindingSource()
orders_BindingSource.DataSource = myDataSet
orders_BindingSource.DataMember = "Orders"
ordersDetail_BindingSource.DataSource = orders_BindingSource
ordersDetail_BindingSource.DataMember = "Order_OrderDetails"
dgvOrders.DataSource = orders_BindingSource
dgvOrderDetails.DataSource = ordersDetail_BindingSource
End Sub
Date :
2012-12-12 10:03:20
By :
tee
Load balance : Server 05