Home > Net >  The use of vb.net in the datagridview
The use of vb.net in the datagridview

Time:10-07

How to query button can find I need conditions, such as start date and end date, according to the data in the datagridview between how the information recorded at the same time, changes to the database, the code, I am novice, thank you! All this points to the

CodePudding user response:

According to the start date and end date first query to the DataTable, then your datagridview1. The DataSource=dt, can display, the following code, using SQl Server database,
You modified use Updata update
 
Dim mySQL As String

MySQL="SELECT SN AS model, StartTime AS the start time, EndTime AS end time, IsOK AS state" & amp; _
"FROM tb_Data_ChaXiaoU" & amp; _
"WHERE StartTime>='" & amp; Format (DateTimePicker1. Value, "yyyy - MM - dd) & amp; "00:00:00. 000 'AND EndTime & lt;='" & amp; Format (DateTimePicker2. Value, "yyyy - MM - dd) & amp; "23:59:59. 000 '"
'dataadapters executing SQL statements
Dim adapter As New SqlClient. SqlDataAdapter (mySQL, myCon)
Dim dt As New DataTable (" myQuery ")


Adapter. The Fill (dt)
Dgv_DataQuery. The DataSource=dt



Modify the

 
'to write data in the database
Dim mySQLstr As String
MySQLstr="UPDATE tb_Data_ChaXiaoU_Model SET SAP=@ _SAP, UCount=@ _UCount WHERE Model=@ _Model"
Dim cmd1 As New SqlClient. SqlCommand (mySQLstr myCon)
Cmd1. The Parameters. The Add (New SqlClient. SqlParameter (" @ _Model, "txt_Model. Text))
Cmd1. The Parameters. The Add (New SqlClient. SqlParameter (" @ _SAP, "txt_SAP. Text))
Cmd1. The Parameters. The Add (New SqlClient. SqlParameter (" @ _UCount ", Val (txt_UCount. Text)))
Try
MyCon. The Open ()
Cmd1. ExecuteNonQuery ()
MyCon. Close ()
Catch the ex As Exception
MyCon. Close ()
End the Try

CodePudding user response:

It seems hard, I suggest you VB.NET SQL operation under the baidu

CodePudding user response:

reference 1/f, lover and response:
according to the start date and end date first query to the DataTable, then your datagridview1. The DataSource=dt, can display, the following code, using SQl Server database,
You modified use Updata update
 
Dim mySQL As String

MySQL="SELECT SN AS model, StartTime AS the start time, EndTime AS end time, IsOK AS state" & amp; _
"FROM tb_Data_ChaXiaoU" & amp; _
"WHERE StartTime>='" & amp; Format (DateTimePicker1. Value, "yyyy - MM - dd) & amp; "00:00:00. 000 'AND EndTime & lt;='" & amp; Format (DateTimePicker2. Value, "yyyy - MM - dd) & amp; "23:59:59. 000 '"
'dataadapters executing SQL statements
Dim adapter As New SqlClient. SqlDataAdapter (mySQL, myCon)
Dim dt As New DataTable (" myQuery ")


Adapter. The Fill (dt)
Dgv_DataQuery. The DataSource=dt



Modify the

 
'to write data in the database
Dim mySQLstr As String
MySQLstr="UPDATE tb_Data_ChaXiaoU_Model SET SAP=@ _SAP, UCount=@ _UCount WHERE Model=@ _Model"
Dim cmd1 As New SqlClient. SqlCommand (mySQLstr myCon)
Cmd1. The Parameters. The Add (New SqlClient. SqlParameter (" @ _Model, "txt_Model. Text))
Cmd1. The Parameters. The Add (New SqlClient. SqlParameter (" @ _SAP, "txt_SAP. Text))
Cmd1. The Parameters. The Add (New SqlClient. SqlParameter (" @ _UCount ", Val (txt_UCount. Text)))
Try
MyCon. The Open ()
Cmd1. ExecuteNonQuery ()
MyCon. Close ()
Catch the ex As Exception
MyCon. Close ()
End the Try

I am using the access don't know what is the difference between can help modify, beginner vb.net, bit by bit to understand only by code in the form, thank you

CodePudding user response:

refer to the second floor it_gz_xi response:
it seems hard, I suggest that you own VB.NET SQL operation under the baidu

For may be easy to you,

CodePudding user response:

reference 4 floor drum response:
Quote: refer to the second floor it_gz_xi response:

It seems hard, I suggest you VB.NET SQL operation under the baidu

Is is easy, for you may

Do you have difficulty that step

CodePudding user response:

reference 5 floor ManBOyyy reply:
Quote: refer to 4th floor drum response:

Quote: refer to the second floor it_gz_xi response:

It seems hard, I suggest you VB.NET SQL operation under the baidu

Is is easy, for you may

Do you have difficulty ah that step

Can provide the complete code? Thank god

CodePudding user response:


Query

 

Dim strFilePath As String=AppDomain. CurrentDomain. SetupInformation. ApplicationBase 'strFilePath
Dim myCon As New OleDbConnection (" Provider=Microsoft. Jet. The Oledb. 4.0; The Jet OLEDB: Database Password=sa123; Data Source="& amp; StrFilePath & amp; "DataBase \ Common MDB")

Dim mySQL As String


MySQL="SELECT BarCodeItem AS Item barcode, BarCodeCTN AS CTN bar code, Destination AS sent, DistributeLine AS distribution line, Curdate AS distribution date FROM ProductStock" & amp; _
"WHERE CurDate>='" & amp; Format (DateTimePicker1. Value, "yyyy - MM - dd) & amp; "00:00:00 'AND CurDate & lt;='" & amp; Format (DateTimePicker2. Value, "yyyy - MM - dd) & amp; "23:59:59 '
"
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related