|
|
|
ExecuteNonQuery error พี่ลองใช้ifดักแล้วแบบนี้แต่มันยังerrorที่เดิมอ่า comAdd1.ExecuteNonQuery() |
|
|
|
|
|
|
|
พี่ลองใช้ifดักแล้วแบบนี้แต่มันยังerrorที่เดิมอ่า
comAdd1.ExecuteNonQuery()
Code (ASP)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConn As String = WebConfigurationManager.ConnectionStrings("Genius").ConnectionString
Dim Conn As New SqlConnection(strConn)
'-------------------------------------------------------Personal Data------------------------------------------------------------------
Dim ID As String
'ID = "Tc_"+ date("U")
ID = "Tc_1234567890"
Dim User = Session("Username")
Dim Pass = Session("Pass")
Dim Email = Session("Email")
Dim first = Session("first")
Dim firstname = Session("firstname")
Dim last = Session("lastname")
Dim status = "0"
Dim heigth = Session("heigth")
Dim weigth = Session("weigth")
Dim gender = Session("gender")
Dim marry = Session("marry")
Dim child = Session("child")
Dim Nation = Session("Nationality")
Dim Origin = Session("Origin")
Dim religion = Session("Religion")
Dim birth = Session("Date")
Dim Smoke = Session("Smoke")
Dim drink = Session("drink")
Dim street1 = Session("street_current")
Dim district1 = Session("district_current")
Dim Country1 = Session("country_current")
Dim Zip1 = Session("zip_current")
Dim tele1 = Session("tele_current")
Dim contact1 = Session("contact_current")
Dim street2 = Session("street_origin")
Dim district2 = Session("district_origin")
Dim Country2 = Session("country_origin")
Dim Zip2 = Session("zip_origin")
Dim tele2 = Session("tele_origin")
Dim contact2 = Session("contact_origin")
Dim hight = Session("hight")
Dim hight_ins = Session("hight_ins")
Dim hight_major = Session("hight_major")
Dim hight_branch = Session("hight_branch")
Dim hight_date = Session("hight_date")
Dim hight_GPA = Session("hight_GPA")
Dim sec = Session("sec")
Dim sec_ins = Session("sec_ins")
Dim sec_major = Session("sec_major")
Dim sec_branch = Session("sec_branch")
Dim sec_GPA = Session("sec_GPA")
' Dim encode = MD5(Pass)
Dim sqlAdd1 As String
Dim comAdd1 As New SqlCommand
If ID.ToString = "" Or User.ToString = "" Or Pass.ToString = "" Or first.ToString = "" Or firstname.ToString = "" Or last.ToString = "" Or status.ToString = "" Or heigth.ToString = "" Or weigth.ToString = "" Or gender.ToString = "" Or Email.ToString = "" Or marry.ToString = "" Or child.ToString = "" Or Nation.ToString = "" Or Origin.ToString = "" Or religion.ToString = "" Or birth.ToString = "" Or Smoke.ToString = "" Or drink.ToString = "" Or street1.ToString = "" Or district1.ToString = "" Or Country1.ToString = "" Or Zip1.ToString = "" Or tele1.ToString = "" Or street1.ToString = "" Or district2.ToString = "" Or Country2.ToString = "" Or Zip2.ToString = "" Or tele2.ToString = "" Or hight.ToString = "" Or hight_ins.ToString = "" Or hight_major.ToString = "" Or hight_branch.ToString = "" Or hight_date.ToString = "" Or hight_GPA.ToString = "" Or sec.ToString = "" Or sec_ins.ToString = "" Or sec_branch.ToString = "" Or sec_GPA.ToString = "" Then
MsgBox("null", MsgBoxStyle.OkOnly)
Else
sqlAdd1 = "INSERT INTO Teacher(ID_Tc,Username,Password,First_Tc,Name_Tc,Sur_Tc,Status,Heigth,Weigth,Gender,email_Tc,marry,Num_child,nationality,origin,religion,Date_birth,Smoke,Drink,Street_Cur,District_Cur,Country_Cur,Zip_Cur,Tel1_Tc,Street_ori,District_ori,Country_ori,Zip_ori,Tel2_Tc,Hight_Level,Hight_Ins,Hight_Major,Hight_Branch,Hight_Since,Hight_GPA,Sec_Level,Sec_Ins,Sec_Major,Sec_Branch,Sec_GPA)"
sqlAdd1 = " VALUES('" & ID.ToString & "',"
sqlAdd1 = "'" & User.ToString & "',"
sqlAdd1 = "'" & Pass.ToString & "',"
sqlAdd1 = "'" & first.ToString & "',"
sqlAdd1 = "'" & firstname.ToString & "',"
sqlAdd1 = "'" & last.ToString & "',"
sqlAdd1 = "'" & status.ToString & "',"
sqlAdd1 = "'" & heigth.ToString & "',"
sqlAdd1 = "'" & weigth.ToString & "',"
sqlAdd1 = "'" & gender.ToString & "',"
sqlAdd1 = "'" & Email.ToString & "',"
sqlAdd1 = "'" & marry.ToString & "',"
sqlAdd1 = "'" & child.ToString & "',"
sqlAdd1 = "'" & Nation.ToString & "',"
sqlAdd1 = "'" & Origin.ToString & "',"
sqlAdd1 = "'" & religion.ToString & "',"
sqlAdd1 = "'" & birth.ToString & "',"
sqlAdd1 = "'" & Smoke.ToString & "',"
sqlAdd1 = "'" & drink.ToString & "',"
sqlAdd1 = "'" & street1.ToString & "',"
sqlAdd1 = "'" & district1.ToString & "',"
sqlAdd1 = "'" & Country1.ToString & "',"
sqlAdd1 = "'" & Zip1.ToString & "',"
sqlAdd1 = "'" & tele1.ToString & "',"
sqlAdd1 = "'" & street1.ToString & "',"
sqlAdd1 = "'" & district2.ToString & "',"
sqlAdd1 = "'" & Country2.ToString & "',"
sqlAdd1 = "'" & Zip2.ToString & "',"
sqlAdd1 = "'" & tele2.ToString & "',"
sqlAdd1 = "'" & hight.ToString & "',"
sqlAdd1 = "'" & hight_ins.ToString & "',"
sqlAdd1 = "'" & hight_major.ToString & "',"
sqlAdd1 = "'" & hight_branch.ToString & "',"
sqlAdd1 = "'" & hight_date.ToString & "',"
sqlAdd1 = "'" & hight_GPA.ToString & "',"
sqlAdd1 = "'" & sec.ToString & "',"
sqlAdd1 = "'" & sec_ins.ToString & "',"
sqlAdd1 = "'" & sec_major.ToString & "',"
sqlAdd1 = "'" & sec_branch.ToString & "',"
sqlAdd1 = "'" & sec_GPA.ToString & "')"
Conn.Open()
comAdd1 = New SqlCommand(sqlAdd1, Conn)
comAdd1.ExecuteNonQuery()
Conn.Close()
'-----------------------------------------------------------------------------------------------------------------
'------------------------------------------Edu and Ex-------------------------------------------------------
Dim from1 = Session("from1")
Dim to1 = Session("to1")
Dim company1 = Session("company1")
Dim com_add1 = Session("com_add1")
Dim position1 = Session("position1")
Dim salary1 = Session("salary1")
Dim job1 = Session("job1")
Dim sqlAdd2 As String
Dim comAdd2 As New SqlCommand
sqlAdd2 = "insert into Experience_Tc(ID_Tc,Ex_From,Ex_To,Company,Company_Add,Position,Salary,Job_Des,No_Ex)"
sqlAdd2 = " values ('" & ID.ToString & "',"
sqlAdd2 = "'" & from1.ToString & "',"
sqlAdd2 = "'" & to1.ToString & "',"
sqlAdd2 = "'" & company1.ToString & "',"
sqlAdd2 = "'" & com_add1.ToString & "',"
sqlAdd2 = "'" & position1.ToString & "',"
sqlAdd2 = "'" & salary1.ToString & "',"
sqlAdd2 = "'" & job1.ToString & "',"
sqlAdd2 = "'1')"
Conn.Open()
comAdd2 = New SqlCommand(sqlAdd2, Conn)
comAdd2.ExecuteNonQuery()
Conn.Close()
End If
Tag : - - - -
|
|
|
|
|
|
Date :
2009-12-04 09:53:13 |
By :
LuckyStar |
View :
1161 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดีบั๊กเอาคำสั้ง sql ที่บรรทัด103ไปรันใน sql ดูครับ
แล้วมัน error ว่าไรเหรอครับ
|
|
|
|
|
Date :
2009-12-04 11:50:41 |
By :
otomokung |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
sqlAdd2 = "'" & from1.ToString & "',"
sqlAdd2 = "'" & to1.ToString & "',"
มันดูเหมือน กัน กำหนดค่ามากกว่าต่อ String นะครับ มันหน้าจะเป็น เพราะถ้า C# มันจะเป็น
sqlAdd2 += "'" + to1.ToString + "',"
ตรวจสอบวิธีการต่อ STring นะครับ
ลองแก้ด้วยหารใช้ StringBuilder ดูนะครับ
๊
Code (C#)
using System.Text;
StringBuildder str = new StringBuildder();
str.Append("INSERT INTO Teacher(ID_Tc,Username,Password) values (");
str.Append("'" + ID.ToString + "',");
str.Append("'" + from1.ToString + "',");
str.Append("'" + company1.ToString + "')");
comAdd2 = New SqlCommand(str.ToString(), Conn)
ตัวอย่าง C# ครับ ลองปรกยุกดูนะครับ ^^
|
|
|
|
|
Date :
2009-12-04 12:08:53 |
By :
ksillapapan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2010-08-06 14:00:43 |
By :
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|