Home > Net >  Windows forms application, vb.net, program the impassability, for bosses.
Windows forms application, vb.net, program the impassability, for bosses.

Time:11-26

Imports System. Data
Imports System. The Data. SqlClient

Public Class guanliyuanxinxiweihu
Private connstr As String="Data Source=i75 DESKTOP - 7740; Initial Catalog=SPGL; Integrated Security=True "
Private conn As New SqlConnection (connstr)
Dim num As Integer=0
Private Sub guanliyuanxinxiweihu_Load (sender As Object, As EventArgs e) Handles MyBase. Load
'TODO: this line of code to load data into the table "SPGLDataSet4. GLY", you can according to the need to move or delete it,
Me. GLYTableAdapter2. The Fill Me. SPGLDataSet4. (GLY)
'TODO: this line of code to load data into the table "SPGLDataSet2. GLY", you can according to the need to move or delete it,
Me. GLYTableAdapter. The Fill Me. SPGLDataSet2. (GLY)

End Sub

Private Sub DataGridView1_CellDoubleClick (sender As Object, e As DataGridViewCellEventArgs)
TextBox1. Text=DataGridView1. Rows (" e.R owIndex), Cells (1). The Value. The ToString
TextBox2. Text=DataGridView1. Rows (" e.R owIndex), Cells (2). The Value. The ToString
TextBox3. Text=DataGridView1. Rows (" e.R owIndex), Cells (3). The Value. The ToString
TextBox4. Text=DataGridView1. Rows (" e.R owIndex), Cells (4). The Value. The ToString
TextBox5. Text=DataGridView1. Rows (" e.R owIndex), Cells (5). The Value. The ToString
Num="e.R owIndex
End Sub

Private Sub Button1_Click (sender As Object, As EventArgs e) Handles for. Click
Dim sqlstring As String
Dim num1 As Integer=0
Sqlstring=""
Sqlstring & amp;="declare cc2 cursor
"Sqlstring & amp;="for the select * from GLY"
Sqlstring & amp;="open cc2
"
While num1 & lt; Num
Sqlstring & amp;="fetch next from cc2"
Num1 +=1
End While

Sqlstring & amp;="update GLY
"Sqlstring=sqlstring & amp; "The set ID='" & amp; TextBox1. Text & amp; "', GNAME=" & amp; TextBox2. Text & amp; "', GADDRESS=" & amp; TextBox3. Text & amp; "',
GTEL='" & amp; TextBox4. Text & amp; "', GZCRI=" & amp; TextBox5. Text & amp; "'
"Sqlstring & amp;="where the current of cc2"

Dim SQLCMD As New SqlCommand (sqlstring, conn.)
Conn. The Open ()
SQLCMD. ExecuteNonQuery ()
Conn. Close ()
Call guanliyuanxinxiweihu_Load (Nothing, Nothing)
End Sub

Private Sub Button2_Click (sender As Object, As EventArgs e) Handles Button2. Click
Dim cellvalue As Object=False
Dim a (100) As a Boolean
Dim I, j As Integer
Dim num As Integer
For I=0 To 100
A (I)=False

Next
Num=Me. DataGridView1. RowCount
For j=0 To 2
num -Cellvalue=https://bbs.csdn.net/topics/DataGridView1.Rows (j) Cells (0). The Value
If cellvalue=https://bbs.csdn.net/topics/True Then
A (j)=True
Cellvalue=https://bbs.csdn.net/topics/False
End the If

Next
Dim sqlstring As String
Dim num2 As Integer=0
Sqlstring=""
Sqlstring=sqlstring & amp; "Declare cc3 cursor
"Sqlstring=sqlstring & amp; "For the select * from GLY"
Sqlstring=sqlstring & amp; "The open cc3
"
While num2 & lt; Num 1
Sqlstring=sqlstring & amp; "Fetch next from cc3
"If a (num2)=True Then
Sqlstring=sqlstring & amp; "The delete from GLY
"Sqlstring=sqlstring & amp; "Where the current of cc3
"
End the If
Num2=num2 + 1
End While

Dim SQLCMD As New SqlCommand (sqlstring, conn.)
Conn. The Open ()
SQLCMD. ExecuteNonQuery ()
Conn. Close ()

Call guanliyuanxinxiweihu_Load (Nothing, Nothing)
End Sub

Private Sub Button3_Click (sender As Object, As EventArgs e) Handles Button3. Click
Me. The Close ()
Guanliyuanmain. The Show ()
End Sub
The End of the Class
Running shows that System. The Data. SqlClient. SqlException: "not line within the current extraction buffer,
The statement has been terminated, "
Is ultimately to achieve the datagridview double-click on the incident, the data showed in textboxs,

CodePudding user response:

According to the prompt is not read the data to the table, is there a data breakpoints view the data table?

CodePudding user response:

Can be deleted, but also display, and then double-click event also can appear again in the textbox, is unable to update the Data, has been display System. The Data. SqlClient. SqlException: "not line within the current extraction buffer,
The statement has been terminated, "

CodePudding user response:

Access control characters before and after adding wildcards and proved,

CodePudding user response:

Also note to remove Spaces,