Home > Software engineering >  Bosses genuflect is begged!!!!! Help, vb programming to connect to the database, the adapter. Why th
Bosses genuflect is begged!!!!! Help, vb programming to connect to the database, the adapter. Why th

Time:09-17

The code below
Private Sub Button1_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles for. Click
Dim myconn As SqlConnection=New SqlConnection (" database=online bookstore database; Data source=. Integrated security=true;" )
Dim mysql As String="select customercode As customer number, the name As the name, sex, sex As job As professional, birthday As date of birth, hometown As native, email As email, telephone As mobile phone Numbers, vipclass As customer rating, loyaltyclass As customer loyalty from customer where name like '%" & amp; TextBox1. Text & amp; "% '
"Dim myadapter As New SqlDataAdapter (mysql, myconn)
Dim mydataset As New DataSet
Myadapter. The Fill (mydataset, "customer")
DataGridView1. The DataSource=mydataset. Tables (0)
End Sub

CodePudding user response:

Tell what's wrong??????????????????????????????????????????????
Say first code can see out, your sqlconnection does not open;
You want to fill in the dataset of the fill to a nonexistent datatable, I haven't tried, could find objects are available, and also could be created automatically, but itself is sqldataadapter can fill to a datatable, if there are no special requirements, the datatable more convenient than the dataset,
 Dim Datatable1 As New DataTable 
Myadapter. The Fill (Datatable1)
DataGridView1. The DataSource=Datatable1

CodePudding user response:

The
refer to the original poster MCOLF response:
code below
Private Sub Button1_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles for. Click
Dim myconn As SqlConnection=New SqlConnection (" database=online bookstore database; Data source=. Integrated security=true;" )
Dim mysql As String="select customercode As customer number, the name As the name, sex, sex As job As professional, birthday As date of birth, hometown As native, email As email, telephone As mobile phone Numbers, vipclass As customer rating, loyaltyclass As customer loyalty from customer where name like '%" & amp; TextBox1. Text & amp; "% '
"Dim myadapter As New SqlDataAdapter (mysql, myconn)
Dim mydataset As New DataSet
Myadapter. The Fill (mydataset, "customer")
DataGridView1. The DataSource=mydataset. Tables (0)
End Sub

Punctuation marks clearly wrong, both single-byte commas, also have double byte comma,
Dim mysql As String="select customercode As customer number, the name As the name, sex, sex As job As professional, birthday As date of birth, hometown As native, email As email, telephone As mobile phone Numbers, vipclass As customer rating, loyaltyclass As customer loyalty from customer where name like '%" & amp; TextBox1. Text & amp; "% '
"To:
Dim mysql As String="select customercode As customer number, the name As the name, sex, sex As job As professional, birthday As date of birth, hometown As native, email As mail, telephone As mobile phone Numbers, vipclass As customer rating, loyaltyclass As customer loyalty from customer where name like '%" & amp; TextBox1. Text & amp; "% '
"

CodePudding user response:

About whether he is suitable for programming is very simple test:
On a newspaper or magazine articles, for a period of about 1000 words in Word input again, after losing to refer to the following answer:

A. there are more than 10 words or punctuation
B there is no words or punctuation mistakes and dare to bet for this
No words or punctuation errors and C fonts and layout fully consistent with the original
D print on the translucent paper and check the same original overlap, and feel very with a sense of accomplishment

A is not suitable for programming (reason: typing accuracy is low, careless)
B junior programmer (reason: typing accuracy high, careful and meticulous, confident, understand the whole Angle of half Angle concept)
C senior programmer (reason: in the B on the basis of understanding the font and layout is also an important factor of computer to print, but compared to D paranoid enough, strives for perfection, the results can verify)
D software project manager (reason: to be able to give convincing for project detailed requirements to the pole and typical test cases, users almost pick is not at fault, major!)

If want to from A to B, to my resources http://download.csdn.net/detail/zhao4zhong1/4084259 download "for programmers keyboard practice"

CodePudding user response:

Thank you, have been solved
  • Related