 |
|
เขียนโปรแกรมร้านอินเตอร์เน็ต โค้ดError ครับช่วแก้ที |
|
 |
|
|
 |
 |
|

Error แรกครับ บ้างที่ก็เป็นเลข1

อันนี้เคยเป็นแล้วรอบหนึ่งเพราะเขียนinto ผิด ผมก็คิดว่าน่าจะมีคำผิดรึป่าวแต่นี้ตรวจมา5รอบแล้วก็ยังไม่เจอ
ส่วนนี้โค้ดทั้งหมดครับ
Code (VB.NET)
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Windows.Forms.Application
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim OldThreading = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
Dim Cmd As SqlCommand
Dim MySQL As String
If TextBox1.Text = "" Then
MySQL = "Insert Into Officer(Name,Surname,Birthday,LoginRight,Username,Password)"
MySQL += "Values(" ' & TextBox2.Text & '","' & TextBox3.Text & '",'"
MySQL += Format(DateTimePicker1.Value, "MM/dd/yyyy") & "'," & CheckBox1.CheckState
MySQL += "," ' & TextBox4.Text & '","' & TextBox5.Text & '")"
Else
MySQL = "update Officer Set Name =" ' & TextBox2.Text & '",Surname="' & TextBox3.Text & '","
MySQL += "Birthday=" ' & Format(DateTimePicker1.Value, "MM/dd/yyyy") & '","
MySQL += "LoginRight=" & CheckBox1.CheckState & ",Username=" ' & TextBox4.Text& '","
MySQL += "Password=" ' & TextBox5.Text&"'Where OfficeID =" & TextBox1.Text
End If
Cmd = New SqlCommand(MySQL, Con)
Cmd.ExecuteNonQuery()
System.Threading.Thread.CurrentThread.CurrentCulture = OldThreading
MsgBox("บันทึกรายการเรียบร้อย")
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
CheckBox1.Checked = False
CheckBox2.Checked = True
DateTimePicker1.Value = Today.Date
GroupBox1.Enabled = False
DataGridView1.Enabled = True
Call DisplayDGV()
End Sub
Private Sub DisplayDGV()
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim MySQL As String
MySQL = "select OfficeID รหัส,Name+''+Surname ชื่อสกุล,Birthday วันเกิด,LoginRight สิทธิ์"
MySQL += "from Officer"
Dim DataT As New DataTable
Dim DataA = New SqlDataAdapter(MySQL, Con)
DataA.Fill(DataT)
Me.DataGridView1.DataSource = DataT
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GroupBox1.Enabled = False
TextBox1.ReadOnly = True
TextBox4.Enabled = False
TextBox5.Enabled = False
CheckBox2.Checked = True
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Call DisplayDGV()
End Sub
Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
If DataGridView1.RowCount = 0 Then
Exit Sub
End If
TextBox1.Text = DataGridView1.CurrentRow.Cells(0).Value
DataGridView1.Enabled = False
GroupBox1.Enabled = True
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim MyReader As SqlDataReader
Dim Cmd As SqlCommand
Dim MySQL As String
MySQL = "Select*from Officer Where Officeid=" & Val(TextBox1.Text)
Cmd = New SqlCommand(MySQL, Con)
MyReader = Cmd.ExecuteReader
MyReader.Read()
If MyReader.HasRows Then
TextBox2.Text = MyReader("Name")
TextBox3.Text = MyReader("Surname")
DateTimePicker1.Value = MyReader("Birthday")
CheckBox1.Checked = MyReader("loginright")
TextBox4.Text = MyReader("Username")
TextBox5.Text = MyReader("Password")
End If
Con.Close()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox4.Enabled = True
TextBox5.Enabled = True
Else
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox4.Clear()
TextBox5.Clear()
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox5.PasswordChar = "*"
Else
TextBox5.PasswordChar = ""
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim Cmd As SqlCommand
Dim MySQL As String
MySQL = "Delete From Officer Where OfficeID =" & TextBox1.Text
If TextBox1.Text <> "" Then
End If
If MsgBox("ท่านต้องการลบฐานข้อมูลนี้ใช้หรือไหม", MsgBoxStyle.Critical + MsgBoxStyle.YesNo) =
MsgBoxResult.Yes Then
Cmd = New SqlCommand(MySQL, Con)
Cmd.ExecuteNonQuery()
Else
End If
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
CheckBox1.Checked = False
CheckBox2.Checked = True
DateTimePicker1.Value = Today.Date
GroupBox1.Enabled = False
DataGridView1.Enabled = True
Call DisplayDGV()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
GroupBox1.Enabled = True
CheckBox1.Checked = False
CheckBox2.Checked = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
End Class

รูปนี้คือแบบดีไซครับ datagridview ก็ไม่แสดง ทั้งที่ทำตามในหนังสือหมดเลย ประกาศDisplayDGV แต่ลองทำอีกแบบกับขึ้นแต่ในหนังสือที่ซื้อมาอ่านมันมีให้ทำตามเลย ก็เลยลองทำยังผิดอีก TT
ขอบคุณล้วงหน้าเลยน่ะครับ เขียนโปรแกรมตัวนี้ผมต้องนำไปเป็นต้นแบบเขียนเอง เพื่อทำโปรเจคจบด้วย
Tag : .NET, VB.NET
|
|
 |
 |
 |
 |
Date :
2015-11-13 21:22:39 |
By :
holopee |
View :
2189 |
Reply :
19 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้ก็Error เดิม incorrect syntax near
Code (VB.NET)
Private Sub DisplayDGV()
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim MySQL As String
MySQL = "select TableIDรหัส,TableNameโต๊ะบริการ,TableStatusสถานะ"
MySQL += "from Tables"
Dim DataT As New DataTable
Dim DataA = New SqlDataAdapter(MySQL, Con)
DataA.Fill(DataT)
Me.DataGridView1.DataSource = DataT
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim MyReader As SqlDataReader
Dim Cmd As SqlCommand
Dim MySQL As String
MySQL = "SELECT*from Tables Where TableId=" & Val(TextBox1.Text)
Cmd = New SqlCommand(MySQL, Con)
MyReader = Cmd.ExecuteReader
MyReader.Read()
If MyReader.HasRows Then
TextBox2.Text = MyReader("TableName")
If MyReader("TableStatus") Then
RadioButton1.Checked = True
Else
RadioButton2.Checked = True
End If
End If
Con.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim Cmd As SqlCommand
Dim MySQL As String
If TextBox1.Text = "" Then
MySQL = "Insert Into Tables(TableName,TableStatus)"
MySQL += "Values(" ' & TextBox2.Text & '"," & Math.Abs(CInt(RadioButton1.Checked))& ")"
Else
MySQL = "update Tables Set TableName=" ' & TextBox2.Text& '","
MySQL += "TableStatus=" & Math.Abs(CInt(RadioButton1.Checked)) & ""
MySQL += "Where TableID =" & TextBox1.Text
End If
Cmd = New SqlCommand(MySQL, Con)
Cmd.ExecuteNonQuery()
MsgBox("บันทึกรายการเรียบร้อย")
TextBox1.Clear()
TextBox2.Clear()
RadioButton1.Checked = True
GroupBox1.Enabled = False
DataGridView1.Enabled = True
Call DisplayDGV()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim Cmd As SqlCommand
Dim MySQL As String
MySQL = "Delecte From Tables Where TableID = " & TextBox1.Text
If TextBox1.Text <> "" Then
If MsgBox("ท่านต้องการลบการนี้จากฐานข้อมูลใช้หรือไม่", MsgBoxStyle.Critical + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Cmd = New SqlCommand(MySQL, Con)
Cmd.ExecuteNonQuery()
Else
End If
Else
End If
TextBox1.Clear()
TextBox2.Clear()
RadioButton1.Checked = True
GroupBox1.Enabled = False
DataGridView1.Enabled = True
Call DisplayDGV()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
GroupBox1.Enabled = True
RadioButton1.Checked = True
TextBox2.Focus()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.DoubleClick
If DataGridView1.RowCount = 0 Then
Exit Sub
End If
TextBox1.Text = DataGridView1.CurrentRow.Cells(0).Value
DataGridView1.Enabled = False
GroupBox1.Enabled = True
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GroupBox1.Enabled = False
Call DisplayDGV()
End Sub
End Class
|
 |
 |
 |
 |
Date :
2015-11-13 23:49:51 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ Debug ดูค่าตัวแปร SQL ก็จะเห็นเองครับ ว่ามันมี Syntax หรือพวกเครื่องหมายยังผิดอยู่ครับ 
|
 |
 |
 |
 |
Date :
2015-11-14 07:38:17 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โอเคครับ ผมจะลองตรวจดูอีกครั้ง ถ้าไม่ได้ยังไงจะกลับมาข้อคำแนะนำน่ะครับ
|
 |
 |
 |
 |
Date :
2015-11-14 15:05:23 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ไปหลายจุดแล้วครับแต่ก็ติดอันอื่นเรื่อยๆ แก้ ตรงฟันหนูไปที่เป็นฟันหนู3อันเลย งง แต่ก็ยังErrorอยู่ดี ช่วยหน่อยน้ะครับ
|
 |
 |
 |
 |
Date :
2015-11-14 16:10:24 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วแก้ทีครับ
Code (VB.NET)
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Windows.Forms.Application
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim OldThreading = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
Dim Cmd As SqlCommand
Dim MySQL As String
If TextBox1.Text = "" Then
MySQL = "Insert Into Officer(Name,Surname,Birthday,LoginRight,Username,Password)"
MySQL += "Values(''' & TextBox2.Text & ''',''' & TextBox3.Text & ''','"
MySQL += Format(DateTimePicker1.Value, "MM/dd/yyyy") & "'," & CheckBox1.CheckState
MySQL += ",''' & TextBox4.Text & ''',''' & TextBox5.Text & ''')"
Else
MySQL = "update Officer Set Name =''' & TextBox2.Text &''',Surname=''' & TextBox3.Text &''',"
MySQL += "Birthday=''' & Format(DateTimePicker1.Value, ''MM/dd/yyyy'') &''',"
MySQL += "LoginRight=" & CheckBox1.CheckState & ",Username=''' & TextBox4.Text& ''',"
MySQL += "Password=''' & TextBox5.Text &'''Where OfficeID =" & TextBox1.Text
End If
Cmd = New SqlCommand(MySQL, Con)
Cmd.ExecuteNonQuery()
System.Threading.Thread.CurrentThread.CurrentCulture = OldThreading
MsgBox("บันทึกรายการเรียบร้อย")
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
CheckBox1.Checked = False
CheckBox2.Checked = True
DateTimePicker1.Value = Today.Date
GroupBox1.Enabled = False
DataGridView1.Enabled = True
Call DisplayDGV()
End Sub
Private Sub DisplayDGV()
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim MySQL As String
MySQL = "select OfficeID รหัส,Name+''+Surname ชื่อสกุล,Birthday วันเกิด,LoginRight สิทธิ์"
MySQL += "from Officer"
Dim DataT As New DataTable
Dim DataA = New SqlDataAdapter(MySQL, Con)
DataA.Fill(DataT)
Me.DataGridView1.DataSource = DataT
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'InternetcafeDataSet.Officer' table. You can move, or remove it, as needed.
Me.OfficerTableAdapter.Fill(Me.InternetcafeDataSet.Officer)
GroupBox1.Enabled = False
TextBox1.ReadOnly = True
TextBox4.Enabled = False
TextBox5.Enabled = False
CheckBox2.Checked = True
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Call DisplayDGV()
End Sub
Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
If DataGridView1.RowCount = 0 Then
Exit Sub
End If
TextBox1.Text = DataGridView1.CurrentRow.Cells(0).Value
DataGridView1.Enabled = False
GroupBox1.Enabled = True
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim MyReader As SqlDataReader
Dim Cmd As SqlCommand
Dim MySQL As String
MySQL = "Select*from Officer Where Officeid=" & Val(TextBox1.Text)
Cmd = New SqlCommand(MySQL, Con)
MyReader = Cmd.ExecuteReader
MyReader.Read()
If MyReader.HasRows Then
TextBox2.Text = MyReader("Name")
TextBox3.Text = MyReader("Surname")
DateTimePicker1.Value = MyReader("Birthday")
CheckBox1.Checked = MyReader("loginright")
TextBox4.Text = MyReader("Username")
TextBox5.Text = MyReader("Password")
End If
Con.Close()
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox4.Enabled = True
TextBox5.Enabled = True
Else
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox4.Clear()
TextBox5.Clear()
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox5.PasswordChar = "*"
Else
TextBox5.PasswordChar = ""
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Con As SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim Cmd As SqlCommand
Dim MySQL As String
MySQL = "Delete From Officer Where OfficeID =" & TextBox1.Text
If TextBox1.Text <> "" Then
If MsgBox("ท่านต้องการลบฐานข้อมูลนี้ใช้หรือไหม", MsgBoxStyle.Critical + MsgBoxStyle.YesNo) =
MsgBoxResult.Yes Then
Cmd = New SqlCommand(MySQL, Con)
Cmd.ExecuteNonQuery()
Else
End If
Else
End If
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
CheckBox1.Checked = False
CheckBox2.Checked = True
DateTimePicker1.Value = Today.Date
GroupBox1.Enabled = False
DataGridView1.Enabled = True
Call DisplayDGV()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
GroupBox1.Enabled = True
CheckBox1.Checked = False
CheckBox2.Checked = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
End Class
|
 |
 |
 |
 |
Date :
2015-11-15 17:21:55 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ้างอิงการเขียนมาจากไหนรึครับ
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway')
http://www.w3schools.com/sql/sql_insert.asp
|
 |
 |
 |
 |
Date :
2015-11-16 13:40:07 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

เล่มนี้ครับ
|
 |
 |
 |
 |
Date :
2015-11-16 17:47:37 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ยังไม่เข้าใจตรง values อยู่ดีครับ ว่าผมต้องใส่อะไร
อันนี้ภาพในหนังสือครับ

|
 |
 |
 |
 |
Date :
2015-11-16 18:43:01 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หนังสือถูกแล้วครับแต่ที่เอามาใช้เขียนน่ะผิด. เขียนตามหนีงสือครับ
|
 |
 |
 |
 |
Date :
2015-11-16 21:48:34 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี้ก็เขียนตามหนังสือหมดเลยน้ะครับ แต่พอรันแล้วDatagridview ก็ไม่ขึ้นให้ เลยลองผสมการเรียกdatagridviewแบบ อื่นเข้าไป พอบันทึกข้อมูลก็Error ตรงDataT.Faill ตลอดเลยพยายามดูตามหนังสือตลอดเช็คเครื่องหมายต่างๆก็ยังหาไม่เจอ แถมมีปัญหากับเครื่องหมายฟันหนู ที่บ้างทีมีเป็นอันเดียว3อันติดบ้างครั้งก็เป็น2อันแล้ว1 สึงดูจากหนังสือไม่สามารถดูออกได้ เลยอยากให้ทางนี้ช่วยดูให้หน่อย พอแก้ได้สักfromหนึ่ง from ต่อๆไปก็จะรู้วิธีแก้ไขมากขึ้นครับ ข้อความให้ช่วยบอกเป็นจุดๆให้ที่ครับ ส่วนตัวผมคิดว่าน่าจะมีปัญหาตรง DisplayDGV
|
 |
 |
 |
 |
Date :
2015-11-16 22:56:26 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
"Values(''' & TextBox2.Text & ''',''' & TextBox3.Text & ''','"
'''=> ' ' ' กับ '"=> ' "
ต่างกันตรง ' กับ "
ลองเขียนใหม่ดูก็ได้ครับง่ายดี
|
 |
 |
 |
 |
Date :
2015-11-17 08:17:24 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|


ยังไม่ได้เลยครับdatagridview. ก้ไม่ขึ้น
|
 |
 |
 |
 |
Date :
2015-11-17 12:10:29 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เพื่อไม่ให้สับสน ที่ datagridview. ไม่ขึ้น เพราะ รูปแบบ SQL ผิดครับ
ลองบ้านดูแบบ
Select * from officer ดูก็ได้
และ แนะนำลองศึกษาเรื่อง การใช้ตัวแปร ใน SQL ดู
อย่าง Select ttt As tor from officer
|
 |
 |
 |
 |
Date :
2015-11-17 14:18:23 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตกลงวิธีแก้นี้ไม่มีตรงนี้ไม่มีใช้ไหมครับ เพราะตอบไม่ตรงคำถามเลยอยากรู้วิธีแก้ตรงนี้ครับเพราะทั้งที่ทำตามหนังสือแล้วกับไม่ได้เลยมาถามวิธีแก้ที่เป็นรูปธรรม แก้ตรงนี้เป็นแบบนี้ แล้วจะหาย ศึกษาแล้วครับแต่ก็ังไม่เข้าใจถึงได้มาถาม
|
 |
 |
 |
 |
Date :
2015-11-17 17:17:46 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อืมครับ เข้าใจว่าต้องการคำตอบที่ถูกต้องเอาเป็นว่าไม่มีใครเข้าเอาโค้ดที่คุณเขียนไปเขียนใหม่แล้วหาจุดที่เกิด Error แล้วแก้มาตอบให้หรอกนะ
เพราะทุกคนเขาก็ดูจาก Error ที่แสดงขึ้นมาเท่านั้นผมว่าผมเห็นแล้วละ
Dim MySQL As String
MySQL = "select OfficeID รหัส,Name+''+Surname ชื่อสกุล,Birthday วันเกิด,LoginRight สิทธิ์"
MySQL += "from Officer"
เห็นอะไรไหมครับ ถ้าต่อคำมันจะได้
select OfficeID รหัส,Name+''+Surname ชื่อสกุล,Birthday วันเกิด,LoginRight สิทธิ์from Office
อย่างไงก็ไม่แสดง ว่าแต่ mysql มันไม่มี as เหรอครับ
select OfficeID as'รหัส',(Name+''+Surname ) as 'ชื่อสกุล',Birthday as 'วันเกิด',LoginRight as 'สิทธิ์' from Office
ลองเอาไปรันดูที่ MySQL Query Browser ดูครับว่ารันผ่านหรือเปล่า
อย่าให้ผมได้ไล่ไปอ่านหนังสือเกี่ยวกับ Database อีกคนนะครับ
และ ไม่ว่าจะ Insert Update Delete Select ให้เราลองเขียนและรัน Query ที่ Database ก่อนก็ได้
จะได้พบปัญหาก่อนที่จะมาเขียนผูกกับ Control ต่างๆครับ
ลองดูนะครับ
ผมทิ่งเมล์ให้ก็แล้วกัน [email protected],ผมไม่ได้เก่งแต่ผมมีพี่ goo (google) ครับ
|
 |
 |
 |
 |
Date :
2015-11-17 17:41:59 |
By :
บัญดิษฐ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับขอบคุณมากครับ ไม่ใช้ว่าผมไม่หาข้อมูลไม่อ่านน้ะผมทำล้วอ่านจากเว็บจากหนังสือพยายามลองเปลี่ยนโค้ดแต่มันไม่ได้ยิ่งอ่านก็ยิ่งไม่เข้าใจ จะบอกผมโง่ก็ได้ไม่โกรธเพราะไม่เข้าใจจริงๆเปิดดูyoutubeก็เปิด แต่ที่เขาสนมันไม่ใช้กับที่เราทำพายามดัดแปลงก็ได้สักที ผมไม่ได้ต้องการให้มาแก้เขียนโค้ดให้ทั้งหมดหรอกครับเพราะเวลาจริงผมก็ทำไม่ได้ แต่ว่าตรงนี้มันสุดๆแล้วเวลาก็ใกล้เข้ามา ี่ผมเขียนโค้ดอื่นเพิ่มเขาไปเพราะตรงนี้มันทำไม่ได้ ก็เลยเขียนโค้ดอื่นไปก่อนทำเท่าที่ทำได้ครับ แล้วประกอปด้วยเราดูแบบฟอมนี้มาลอกมาเปะๆเลย แต่มันกลับรันไม่ได้ แต่เขาบอกหนังสือถูก ผมก็อยากรู้ว่าผิดตรงไหนครับ
|
 |
 |
 |
 |
Date :
2015-11-17 17:58:51 |
By :
holopee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
555+++ ขอโทษด้วยครับ ที่ทำให้รู้สึกไม่ดีในคำตอบที่ผมตอบ ผมถือว่าจะตีเหล็กต้องตีที่ไฟร้อนๆครับไม่งั้นเหล็กไม่แกร่ง
อย่างไงก็ขอโทษด้วยนะครับ อย่าท้อละ ขอให้ตั้งใจและศีกษาให้มากมาก ผมผ่านจุดนี้มาแล้ว อย่างไงก็อย่าลืม อ. goo นะครับ
ปรึกษาเรื่องเขียนโปรแกรมได้ทางเมล์ที่ให้ไปนะครับ ไม่คิดตังค์ และไม่รับจ้างเขียนนะครับ เพราะงานที่ทำอยู่ก็มากอยู่แล้วครับผม
|
 |
 |
 |
 |
Date :
2015-11-17 21:04:15 |
By :
บัญดิษฐ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บางครั้งเราต้องใจเยนๆกับปัญหาครับ
ถอยออกมาซักก้าวเพื่อดูองค์รวม
พอดีผมเห็นรูปแบบการเขียนโค้ดแล้วรู้ได้เลยว่าหมักหมม(หมกมุ่น) กับมันจนลืมอะไรหลายๆอย่างไป
ความผิดพลาดทำให้เรารู้วิธีแก้ไขความผิดความครับ 5555
|
 |
 |
 |
 |
Date :
2015-11-18 08:59:01 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะนำให้ใช้ clipboad.settext (คำสั่ง sql) แล้วจะรู้เลยครับว่าอะไรผิด
|
 |
 |
 |
 |
Date :
2015-11-18 09:30:43 |
By :
billkyz5 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|