 |
|
|
 |
 |
|
ติดปัญหาอะไรครับ การ Insert ใช้ผ่าน ADO.NET กับ NameSpace ของ SqlClient สามารถดูได้จากบทความของ ASP.NET กับ SQL Server ครับ
|
 |
 |
 |
 |
Date :
2012-10-15 09:16:28 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Dim Conn As OleDbConnection
Dim cmd As OleDbCommand
Dim sql as string
Conn = New OleDbConnection("Provider=sqloledb;server=" & SVName & ";database=" & DBName & ";uid=" & UID & ";pwd=")
Conn.Open()
sql = "insert into tablename(id,name) select (select isnull(max(id),0) + 1 from tablename),me.txtname.text"
sql = "update tablename set name='xxx' where id="& me.txtid.text
sql = "delete tablename where id="& me.txtid.text
Try
cmd = New OleDbCommand(Sql, Conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show("ets_mc_plan Insert Data Incomplete as" & ex.Message, "Insert Data Error !!!", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
|
 |
 |
 |
 |
Date :
2012-10-15 09:20:16 |
By :
thep |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยดูให้หน่อยครับ
Code (VB.NET)
Dim sqlADD As String 'เก็บคำสั่ง sql สำหรับเพิ่มข้อมูล
Dim cm As New SqlCommand
If txtid.Text = "" Or txtname.Text = "" Or txtsur.Text = "" Or txtno.Text = "" Or txtmoo.Text = "" Or txttumbon.Text = "" Or txtdistrict.Text = "" Or txtprovince.Text = "" Or txtzip.Text = "" Or mttel.Text = "" Or txtex.Text = "" Then
MessageBox.Show("กรุณากรอกข้อมูลให้ครบด้วยครับ..", "คำเตือน", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
Else
MessageBox.Show("คุณต้องการบันทึกข้อมูลใช่หรือไม่?", "ยืนยัน", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
sqlADD = "INSERT INTO teacher(t_id, t_name, t_sur, t_no, t_moo, t_road, t_tumbon, t_district, t_province, t_zip, t_tel, t_exp, t_pic)"
sqlADD &= " VALUE ( '" & txtid.Text & "','" & txtname.Text & "' , '" & txtsur.Text & "' , '" & txtno.Text & "','" & txtmoo.Text & "','" & txttumbon.Text & "', '" & txtdistrict.Text & "','" & txtprovince.Text & "','" & txtzip.Text & "','" & mttel.Text & "','" & txtex.Text & "')"
With cm
.CommandType = CommandType.Text
.CommandText = sqlADD
'.Connection = Conn
.ExecuteNonQuery()
End With
MessageBox.Show("เพิ่มข้อมูลเรียบร้อยแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
|
 |
 |
 |
 |
Date :
2012-10-15 11:16:37 |
By :
pirasak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Error ?
|
 |
 |
 |
 |
Date :
2012-10-15 11:38:41 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คำว่า VALUE ครับ ต้องมี S ต่อท้าย
|
 |
 |
 |
 |
Date :
2012-10-15 11:39:55 |
By :
lee_latee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันขึ้น Eror ตรงนี้ครับ .ExecuteNonQuery()
ช่วยดูให้หน่อย
Code (VB.NET)
Private Sub btsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsave.Click
Dim sqlADD As String 'เก็บคำสั่ง sql สำหรับเพิ่มข้อมูล
Dim cm As New SqlCommand
If txtid.Text = "" Or txtname.Text = "" Or txtsur.Text = "" Or txtno.Text = "" Or txtmoo.Text = "" Or txttumbon.Text = "" Or txtdistrict.Text = "" Or txtprovince.Text = "" Or txtzip.Text = "" Or mttel.Text = "" Or txtex.Text = "" Then
MessageBox.Show("กรุณากรอกข้อมูลให้ครบด้วยครับ..", "คำเตือน", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
clear()
Else
MessageBox.Show("คุณต้องการบันทึกข้อมูลใช่หรือไม่?", "ยืนยัน", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
sqlADD = "INSERT INTO teacher(t_id, t_name, t_sur, t_no, t_moo, t_road, t_tumbon, t_district, t_province, t_zip, t_tel, t_exp, t_pic)"
sqlADD &= " VALUES ( '" & txtid.Text & "','" & txtname.Text & "' , '" & txtsur.Text & "' , '" & txtno.Text & "','" & txtmoo.Text & "','" & txttumbon.Text & "', '" & txtdistrict.Text & "','" & txtprovince.Text & "','" & txtzip.Text & "','" & mttel.Text & "','" & txtex.Text & "')"
'Dim com As New SqlCommand(sqlADD, conn)
With cm
.CommandType = CommandType.Text
.CommandText = sqlADD
.Connection = conn
.ExecuteNonQuery()
End With
MessageBox.Show("เพิ่มข้อมูลเรียบร้อยแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
clear()
End If
End Sub
|
ประวัติการแก้ไข 2012-10-15 16:56:32
 |
 |
 |
 |
Date :
2012-10-15 16:55:39 |
By :
pirasak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอา Error มาดูครับ
|
 |
 |
 |
 |
Date :
2012-10-16 09:13:37 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2012-11-29 16:04:56 |
By :
pirasak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เหมือน t_road จะหายไปนะครับตอน Insert
|
 |
 |
 |
 |
Date :
2012-11-30 11:47:48 |
By :
Casper |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รู้สึก Connection จะหายครับ 
|
 |
 |
 |
 |
Date :
2012-11-30 22:50:01 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนดูโค้ดให้หน่อยค่ะไม่รู้ติดอะไรค่ะ พอกดเพิ่มข้อมูลแล้วมันขึ้น MessageBox ไม่สามารถเพิ่มได้เนื่องจาก Unclosed quotation mark after ther character string 'ข้อมูลที่กรอก)'. iIncorrect syntax near 'ข้อมูลที่กรอก)'.ค่ะ
เหมือนติดตรงที่ขีดเส้นใต้อ่ะค่ะ รบกวนดูให้หน่อยนะค่ะ
Code (VB.NET)
Dim sqlEmployee As String = ""
Dim comEmployee As SqlCommand = New SqlCommand
Dim tmpMSG As String = ""
If (txtEmpID.Text = "") Or (txtEmpName.Text = "") Or (txtEmpPosition.Text = "") Or (txtEmpTel.Text = "") Or (txtUser.Text = "") Or (txtPass.Text = "") Then
MessageBox.Show("กรุณาป้อนข้อมูลสมาชิกให้ครบ !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtEmpID.Focus()
Exit Sub
End If
Try
Select Case ActionFlag
Case "Add"
sqlEmployee = "INSERT INTO Employee (EmployeeID,Emp_Name,Emp_Tel,"
sqlEmployee &= " Emp_Position, Username, Password)"
sqlEmployee &= " VALUES ('" & txtEmpID.Text & "',"
sqlEmployee &= "'" & txtEmpName.Text & "',"
If OptMale.Checked = True Then
sqlEmployee &= "'M',"
ElseIf OptFeMale.Checked = True Then
sqlEmployee &= "'F',"
End If
sqlEmployee &= "'" & txtEmpPosition.Text & "',"
sqlEmployee &= "'" & txtEmpTel.Text & "',"
sqlEmployee &= "'" & txtUser.Text & "',"
sqlEmployee &= "'" & txtPass.Text & "')"
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
If ActionFlag = "Add" Then
tmpMSG = "คุณต้องการเพิ่มข้อมูล ใช่หรือไม่ ?"
ElseIf ActionFlag = "Edit" Then
tmpMSG = "คุณต้องการแก้ไขข้อมูล ใช่หรือไม่ ?"
End If
If MessageBox.Show(tmpMSG, "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
With comEmployee
.CommandType = CommandType.Text
.CommandText = sqlEmployee
.Connection = Conn
.ExecuteNonQuery()
End With
End If
Catch ErrProcess As Exception
MessageBox.Show("ไม่สามารถเพิ่มสมาชิกใหม่ได้ เนื่องจาก " & ErrProcess.Message, "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Exit Sub
End Try
MessageBox.Show("บันทึกลงฐานข้อมูล เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
|
 |
 |
 |
 |
Date :
2012-12-20 03:57:29 |
By :
teaw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองอันนี้ดูนะครับไม่รู้ถูกไหม
Code
sqlEmployee = "INSERT INTO Employee (EmployeeID,Emp_Name,Emp_Sex,Emp_Tel,"
sqlEmployee &= " Emp_Position, Username, Password)"
sqlEmployee &= " VALUES ('" & txtEmpID.Text & "',"
sqlEmployee &= "'" & txtEmpName.Text & "',"
If OptMale.Checked = True Then
sqlEmployee &= "'M',"
ElseIf OptFeMale.Checked = True Then
sqlEmployee &= "'F',"
End If
sqlEmployee &= "'" & txtEmpTel.Text & "',"
sqlEmployee &= "'" & txtEmpPosition.Text & "',"
sqlEmployee &= "'" & txtUser.Text & "',"
sqlEmployee &= "'" & txtPass.Text & "')"
|
 |
 |
 |
 |
Date :
2012-12-21 11:50:57 |
By :
ghosting789 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะ ขอบคุณมากค่ะ
|
 |
 |
 |
 |
Date :
2012-12-27 23:35:19 |
By :
Teaw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนอีกครั้งค่ะ
Code (VB.NET)
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim sqlMember As String = ""
Dim comMember As SqlCommand = Conn.CreateCommand()
Dim tmpMSG As String = ""
If (txtMemberID.Text = "") Or (txtName.Text = "") Or (txtAddress.Text = "") Or (txtTel.Text = "") Then
MessageBox.Show("กรุณาป้อนข้อมูลสมาชิกให้ครบ !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
txtMemberID.Focus()
Exit Sub
End If
If cboPosition.Text = "" Then
MessageBox.Show("กรุณาระบุประเภทสมาชิก !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
cboPosition.Focus()
Exit Sub
End If
Try
Select Case ActionFlag
Case "Add"
sqlMember = "INSERT INTO Member (MemberID,Mem_Num,Mem_Name,Address,Sex,Tel,PositionID)"
sqlMember &= " VALUES ('" & lblMemID.Text & "',"
sqlMember &= "'" & txtMemberID.Text & "',"
sqlMember &= "'" & txtName.Text & "',"
sqlMember &= "'" & txtAddress.Text & "',"
If OptMale.Checked = True Then
sqlMember &= "'M',"
ElseIf OptFemale.Checked = True Then
sqlMember &= "'F',"
End If
sqlMember &= "'" & txtTel.Text & "',"
sqlMember &= "'" & CStr(cboPosition.SelectedValue) & "',"
If CStr(cboPosition.SelectedValue) = "1" Or CStr(cboPosition.SelectedValue) = "2" Then
sqlMember &= "'0','1')"
ElseIf CStr(cboPosition.SelectedValue) = "0" Then
sqlMember &= "'1','0')"
End If
Case "Edit"
sqlMember = "UPDATE Member "
sqlMember &= " SET Mem_Num='" & txtMemberID.Text & "',"
sqlMember &= " Mem_Name='" & txtName.Text & "',"
sqlMember &= " Address='" & txtAddress.Text & "',"
If OptMale.Checked = True Then
sqlMember &= " Sex='M',"
ElseIf OptFemale.Checked = True Then
sqlMember &= " Sex='F',"
End If
sqlMember &= " Tel='" & txtTel.Text & "',"
sqlMember &= " PositionID='" & CStr(cboPosition.SelectedValue) & "'"
sqlMember &= " WHERE (MemberID='" & lblMemID.Text & "')"
End Select
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
If ActionFlag = "Add" Then
tmpMSG = "คุณต้องการเพิ่มข้อมูล ใช่หรือไม่ ?"
ElseIf ActionFlag = "Edit" Then
tmpMSG = "คุณต้องการแก้ไขข้อมูล ใช่หรือไม่ ?"
End If
If MessageBox.Show(tmpMSG, "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
With comMember
.CommandType = CommandType.Text
.CommandText = sqlMember
.Connection = Conn
.ExecuteNonQuery()
End With
End If
Catch ErrProcess As Exception
MessageBox.Show("ไม่สามารถเพิ่มสมาชิกใหม่ได้ เนื่องจาก " & ErrProcess.Message, "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Exit Sub
End Try
MessageBox.Show("บันทึกลงฐานข้อมูล เรียบร้อยแล้ว !!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
grbSearch.Enabled = True
ControlStatus(False)
btnAdd.Enabled = False
btnEdit.Enabled = False
btnSave.Visible = False
btnCancel.Visible = False
ClearData()
grdEquipNotReturn.DataSource = Nothing
btnPrint.Enabled = False
cmdMoveFirst.Enabled = False
cmdMovePrevious.Enabled = False
cmdMoveNext.Enabled = False
cmdMoveLast.Enabled = False
lblShowPositions.Text = ""
txtSearch.Text = ""
txtSearch.Focus()
End Sub
|
 |
 |
 |
 |
Date :
2012-12-30 01:49:02 |
By :
Teaw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
jรูปทีขึ้น Error ของโพส 17 แก้ให้ตรงกับ Column แล้วทำไมยังขึ้นอีกค่ะ

|
 |
 |
 |
 |
Date :
2012-12-30 02:07:50 |
By :
Teaw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2014-11-25 23:09:24 |
By :
tang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
.parameters.AddWithValue("@dot", SqlDbType.Date).Value = Otdate.text
น่าจะเขียนแบบนี้หรือเปล่า (ไม่ชำนาญ)
.parameters.AddWithValue("@dot", DateTime.Parse(Otdate.text) )
|
 |
 |
 |
 |
Date :
2014-11-26 08:32:46 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เคยใช้เขียนแบบ parameter addvalue นะ
เคยแต่เขียนแบบนี้
Code (VB.NET)
dim sql as string
sql = "INSERT INTO OT(No_OT,Date_OT)"
sql &= " VALUES('{0}','{1}'"
sql = String.Format(sql,lblNo_OT.Text,Format(Otdate.text,"MM/dd/yyyy")
หรือเขียนต่อข้อความแบบธรรมดาก็ได้
Code (VB.NET)
dim sql as string
sql = "INSERT INTO OT(No_OT,Date_OT)"
sql &= " VALUES("
sql &= "'" & lblNo_OT.Text & "'"
sql &= ",'" & Format(Otdate.text,"MM/dd/yyyy") & "')"
สาเหตุที่เขียนแบบนี้เพราะมันเขียนสั้นกว่าแล้วก็อ่านได้ง่ายกว่าครับ
และถ้าตอนนี้ยังแก้ปัญหาไม่ได้ให้ลอง debug ดูตัวแปร Odate.text ดูครับว่ามันเป็นค่าอะไรอยู่ทำไมถึงเปลี่ยนเป็น Datetime ไม่ได้
|
ประวัติการแก้ไข 2014-11-26 09:21:48
 |
 |
 |
 |
Date :
2014-11-26 09:21:06 |
By :
deksoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้แบบต่อ string ระวังเจอ sql injection
|
 |
 |
 |
 |
Date :
2014-11-26 09:45:26 |
By :
ห้ามตอบเกินวันละ 2 กระทู้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

Code (VB.NET)
Dim dtset As New DataSet()
If code.Text = "" Then
bname.Text = ""
gtype.Text = ""
gday.Text = ""
gnum.Text = ""
price.Text = ""
MsgBox("กรุณากรอกข้อมูลให้ครบด้วยทุกช่องด้วย", MsgBoxStyle.Information, "ระะบบแจ้งเตือน")
Else
ds.Clear()
Dim cn As New OleDbCommandBuilder(da)
objcurrencymanager.EndCurrentEdit()
Dim irecordchanged As Integer = da.Update(ds, "st_save")
MsgBox("บันทึกข้อมูลสมาชิกลงฐานข้อมูลเรียบร้อยแล้ว" & ControlChars.Lf & _
"จำนวนเรคคอร์ดที่มีการเปลี่ยนแปลงเท่ากับ " & irecordchanged & " เรคคอร์ด", _
, "บันทึกข้อมูลสมาชิก")
dtset.Clear()
code.Text = ""
bname.Text = ""
gtype.Text = ""
gday.Text = ""
gnum.Text = ""
price.Text = ""
End If
พอดีว่าผมทำหน้าบันทึกใน vb.2005 แต่มาเปิดใน vb.2012 แล้วมันบันทึกไม่ได้น่ะคัพ ช่วยที...
|
 |
 |
 |
 |
Date :
2015-01-18 14:37:12 |
By :
นิรนาม |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Convert.ToDateTime(Otdate.Text).ToString("MM/dd/yyyy")
ก่อนจะรันโปรแกรมก็กำหนด CurrentCulture ="en-US" ด้วยนะครับ ปัญหาเรื่องวันที่ก็หมดไป
|
 |
 |
 |
 |
Date :
2015-01-18 18:40:52 |
By :
proogrammer ด้อยปัญญา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยดูไห้หน่อยค่ะมันรันไม่ได้
Code (VB.NET)
Dim sqlADD As String 'เก็บคำสั่ง sql สำหรับเพิ่มข้อมูล
Dim cm As New StdPicture
sqlADD = "INSERT INTO "
sqlADD = "INSERT INTO vacancies_Job(code,order,Product_Name,number,Tel,send,mail,address)"
sqlADD = "VALUES ('" & code.Text & "','" & order.Text & "','" & Product_Name.Text & "','" & Tel.Text & "','" & send.Text & "','" & mail.Text & "','" & address.Text & "',)"
'ใช้ oledbcommand ในการเพิ่มข้อมูล
With cm
.CommandType = CommandType.Text
.CommandText = sqlADD
.Connection = Conn
.Transaction = tr
.Execute NonQuery()
End With
|
 |
 |
 |
 |
Date :
2015-02-23 17:08:57 |
By :
patteera |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยเขียนโปแกรม vb +SQL หน่อยคร๊ หัยแจ้งเตือนพลาสปอตหมดอายุล่วงหน้า2เดือนอ่ะคร๊
|
 |
 |
 |
 |
Date :
2015-05-26 16:59:48 |
By :
ploy |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนขอโค๊ดชุดคำสั่งกดแป้น 1 2 3 4 5 ทุกๆ40วินาทีหน่อยค่ะ vb2010 ค่ะขอบคุณค่ะ
|
 |
 |
 |
 |
Date :
2015-08-25 17:21:14 |
By :
ขอบคุณจ๊ะ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยบอกการทำปุ่มค้นหาให้หน่อยค่ะ พอดีพึ่งหัดทำ
ขอบคุณค่ะ
|
 |
 |
 |
 |
Date :
2016-02-02 17:59:47 |
By :
bee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
Try
If txtCusID.Text = "" Then
MessageBox.Show("Please Select Data", "Update", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtCusID.Focus()
Exit Sub
End If
cm = New OleDbCommand("UPDATE tbFile SET FileNo=@FileNo,Date=@Date,CustomerID=@CustomerID,CustomerName=@CustomerName,TypeName=@TypeName,FileID=@FileID,FileName=@FileName,FilePath1=@FilePath1,FilePath2=@FilePath2,FilePath3=@FilePath3,Remark=@Remark Where FileNo=@FileNo", conn)
cm.Parameters.AddWithValue("@FileNo", txtFileNo.Text)
cm.Parameters.AddWithValue("@Date", Format(CDate(dtpDate.Text), "yyyy-MM-dd"))
cm.Parameters.AddWithValue("@CustomerID", txtCusID.Text)
cm.Parameters.AddWithValue("@CustomerName", txtCusName.Text)
cm.Parameters.AddWithValue("@TypeName", cbType.Text)
cm.Parameters.AddWithValue("@FileID", txtFileID.Text)
cm.Parameters.AddWithValue("@FileName", txtFileName.Text)
cm.Parameters.AddWithValue("@FilePath1", txtSave1.Text)
cm.Parameters.AddWithValue("@FilePath2", txtSave2.Text)
cm.Parameters.AddWithValue("@FilePath3", txtSave3.Text)
cm.Parameters.AddWithValue("@Remark", txtRemark.Text)
cm.ExecuteNonQuery()
MessageBox.Show("Update successful", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information)
ShowFile()
AutoFileNo()
AllClear()
Catch ex As Exception
End Try
End Sub
แนะนำน่อยครับ เวลาคลิกปุ่มแล้วไม่มีอะไรเกีดขื้นเลย แต่พอเอา cm.ExecuteNonQuery() ออก มันค่อยขื้น messagebox มาครับ
|
 |
 |
 |
 |
Date :
2016-05-24 17:18:09 |
By :
มือใหม่ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ย้าย cm.Parameters.AddWithValue("@FileNo", txtFileNo.Text) ไปไว้อันสุดท้าย
แล้วะ เอา FileNo=@FileNo, ใน statement ออก
จำนวน parameter มันไม่เท่ากัน
|
 |
 |
 |
 |
Date :
2016-05-24 21:37:55 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอจะมีโค้ด C# ของ VB 2013 ไหมคะ โค้ดมันหายากมากเลย พอดีทำ เพิ่ม ลบ เเก้ไข อัพเดต อยู่ค่ะ
|
 |
 |
 |
 |
Date :
2016-11-25 10:10:05 |
By :
MoMay |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปกติโปรแกรม vs เขาจะมี sample มี document ให้มาด้วยนะครับ
มีครบทุกอย่างเลย แค่ต้องอ่านเท่านั้นเอง
และที่สำคัญ ถ้าคุณอ่านคุณจะได้ความรู้เยอะมากกๆๆๆๆ
สมัยผมเรียนรู้การใช้ vb ผมอ่านจาก document มันนี่แหล่ะครับ
อ่านมันตั้งแต่หน้าแรกยันหน้า .... (เท่าที่มีเวลาอ่าน ยังอ่านไม่จบจนบัดนี้ 55555 )
แต่รับรองคุณจะได้ความรู้อย่างแท้จริง อันไหนแปลไม่ออก ก็อาศัย พี่กูร์ เอาครับ
สมัยก่อนผมไม่มีพี่กูร์ ต้องเปิด dict ซึ่งบางตัวมันก็ไม่มีต้อง apply (เดา 555) เอาเอง
|
 |
 |
 |
 |
Date :
2016-11-25 10:24:09 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้ติดปัญหา ทำหน้าของมูลพื้นฐานไม่ได้ ปุ๋มเพิ่มลบ แก้ไข บันทึก ดึงข้อมูลไม่โชว์ไม่ได้
รบกวนหน่อยค่ะ ทำไม่ได้จริงๆ. และไม่เก่งในโค้ดเลย
|
 |
 |
 |
 |
Date :
2019-08-21 17:27:18 |
By :
Pr |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไปที่ละ step สร้างหน้าจอ ได้หรือยัง ยังไม่ต้องเชื่อม database
สร้างหน้าจอ ได้แล้ว ควบคุมปุ่ม ได้หรือยัง กดแล้ว เข้าไปยัง code ถูกต้องหรือเปล่า แสดง alert เมื่อกดปุ่ม จะได้รู้ว่าใช่
เมื่อสร้าง ปุ่ม โต้ตอบได้แล้ว
ก็ เริ่มติดต่อกับ database ใสมันใน code ที่รับการกดปุ่มนั่นแหล่ะ ยังไม่ต้องออกแบบให้มันวิลิศมาหรา
insert ได้ก่อน แล้วค่อยไป ทำเรื่อง อ่านข้อมูล เอาให้เข้าใจ
ส่วนการแสดงผล ใช้ เครื่องมือ ของ database แสดงข้อมูลไปก่อน ฝึกไปทีละขั้นเดี๋ยวก็ได้
แต่ถ้าอยากได้โค๊ดเป็นตัวอย่าง แค่ขยันหาเท่านั้น เดี๋ยวก็เจอ ไม่ต้องพึงพาให้ใครหาให้หรอก
เมื่อเขียนโค๊ดแล้วเกิด error แก้ไขเองไม่ได้ ค่อยเอา error มาถาม
ส่วนคำว่าไม่เก่งโค๊ดเลย เมื่ออยากมาทางนี้ก็ต้อง ขวนขวายหน่อยล่ะ
หรือจะให้คนอื่นเขาทำให้ฟรี คิดใหม่เลยถ้าคิดแบบนั้น
|
 |
 |
 |
 |
Date :
2019-08-22 06:06:11 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|