i'm very new so i hope all of u can help me. when i debug my webforms this error occur "An unhandled exception of type 'System.Data.Sq lClient.SqlExce ption' occurred in system.data.dll
Additional information: System error." pls help me solve the problem...thank s..
my code: - Imports System.Data.SqlClient
-
Imports System.Data.OleDb
-
Imports System.Globalization
-
Imports System.Threading
-
-
Public Class PhoneBook
-
Inherits System.Windows.Forms.Form
-
-
Private lsFORMTEXT As String
-
Private lsFINDNAME1, lsFINDNAME2 As String
-
Private lsMODE1 As String
-
Private lsCONSTRSIM, lsCONSTRCSV As String
-
Private lsUSRCODE As String
-
Private lsSQL As String
-
Private oBUTTON As Object
-
Private oMENU As Object
-
Private liBUTTON As Integer
-
Private liMENU As Integer
-
-
Private lsSQLSTR As String
-
Private lsSQLCON As SqlConnection
-
-
Private lsSQLCMD1 As SqlCommand
-
Private lsSQLCBL1 As SqlCommandBuilder
-
Private lsDA1 As SqlDataAdapter
-
Private lsDS1 As DataSet
-
Private lsDT1 As DataTable
-
Private lsDR As DataRow
-
-
Private lsTABLE1 As String = "PhoneBook"
-
Private lsKEY As String = "Name"
-
-
Private cls1 As New clsCon
-
-
Private liLOOP1 As Integer
-
Private liCR As Integer
-
Private liANS As Integer
-
-
Private lsTEXTBOX(2) As TextBox
-
Private lsTEXTBOXNUMBER(0) As TextBox
-
Private lsTEXTBOXINT(2) As TextBox
-
Private lsCOMBOBOX(1) As ComboBox
-
-
Private cTEXTBOX(2) As String
-
Private cTEXTBOXNUMBER(0) As String
-
Private cTEXTBOXINT(2) As String
-
Private cCOMBOBOX(1) As String
-
-
Private liTEXTBOX As Integer = 2
-
Private liTEXTBOXNUMBER As Integer = 0
-
Private liTEXTBOXINT As Integer = 2
-
Private liCOMBOBOX As Integer = 1
-
-
Private lsBUTTON(0) As Object
-
Private lsMENU(0) As Object
-
-
Private Sub PhoneBook_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
lsCONSTRCSV = cls1.SetupText()
-
Me.Text = lsFORMTEXT
-
lbl_gsmode1.Text = lsMODE1
-
lsMODE1 = "VIEW"
-
IniObject()
-
DataPopulate()
-
DataBindClear()
-
DataBind()
-
DataDisplay()
-
End Sub
-
-
Private Sub IniObject()
-
lsTEXTBOX(1) = txt_Name
-
lsTEXTBOX(2) = txt_Address
-
lsTEXTBOXINT(1) = txt_Phone
-
lsTEXTBOXINT(2) = txt_Code
-
lsCOMBOBOX(1) = cbo_State
-
-
cTEXTBOX(1) = "Name"
-
cTEXTBOX(2) = "Address"
-
cTEXTBOXINT(1) = "PhoneNumber"
-
cTEXTBOXINT(2) = "PostalCode"
-
cCOMBOBOX(1) = "State"
-
-
End Sub
-
-
Private Sub DataPopulate()
-
lsSQLSTR = "SELECT * FROM" & lsTABLE1 & "ORDER BY " & lsKEY
-
lsSQLCON = New SqlConnection(lsCONSTRCSV)
-
Dim lsSQLCMD1 As New SqlCommand(lsSQLSTR, lsSQLCON)
-
lsDA1 = New SqlDataAdapter(lsSQLCMD1)
-
Dim lsSQLCMB1 As New SqlCommandBuilder(lsDA1)
-
lsSQLCMB1.GetUpdateCommand() -->'error at here'
-
-
lsDS1 = New DataSet
-
lsDT1 = New DataTable
-
lsDA1.Fill(lsDS1, lsTABLE1)
-
lsDT1 = lsDS1.Tables(0)
-
lsDT1.DefaultView.Sort = lsKEY
-
End Sub
-
-
Private Sub DataBindClear()
-
cls1.Get_DataBindClear(liTEXTBOX, lsTEXTBOX, cTEXTBOX, liTEXTBOXNUMBER, lsTEXTBOXNUMBER, cTEXTBOXNUMBER, liTEXTBOXINT, lsTEXTBOXINT, cTEXTBOXINT, liCOMBOBOX, lsCOMBOBOX, cCOMBOBOX)
-
End Sub
-
-
Private Sub DataBind()
-
cls1.Get_DataBind(liTEXTBOX, lsTEXTBOX, cTEXTBOX, liTEXTBOXNUMBER, lsTEXTBOXNUMBER, cTEXTBOXNUMBER, liTEXTBOXINT, lsTEXTBOXINT, cTEXTBOXINT, liCOMBOBOX, lsCOMBOBOX, cCOMBOBOX, lsDT1)
-
End Sub
-
-
Private Sub DataClear()
-
cls1.Get_DataClear(liTEXTBOX, lsTEXTBOX, cTEXTBOX, liTEXTBOXNUMBER, lsTEXTBOXNUMBER, cTEXTBOXNUMBER, liTEXTBOXINT, lsTEXTBOXINT, cTEXTBOXINT, liCOMBOBOX, lsCOMBOBOX, cCOMBOBOX)
-
End Sub
-
-
Private Sub DataDisplay()
-
cls1.Get_DataDisplay(liTEXTBOX, lsTEXTBOX, cTEXTBOX, liTEXTBOXNUMBER, lsTEXTBOXNUMBER, cTEXTBOXNUMBER, liTEXTBOXINT, lsTEXTBOXINT, cTEXTBOXINT, liCOMBOBOX, lsCOMBOBOX, cCOMBOBOX, lsMODE1)
-
lsTEXTBOX(1).Enabled = IIf(lsMODE1 = "VIEW" Or lsMODE1 = "MODIFY", False, True)
-
End Sub
-
-
Private Sub btn_back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_back.Click
-
If Me.BindingContext(lsDT1).Position <> 0 Then
-
Me.BindingContext(lsDT1).Position -= 1
-
End If
-
End Sub
-
-
Private Sub btn_next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_next.Click
-
If Me.BindingContext(lsDT1).Position < lsDT1.Rows.Count - 1 Then
-
Me.BindingContext(lsDT1).Position += 1
-
End If
-
End Sub
-
-
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu_File_Close.Click
-
Me.Close()
-
End Sub
-
-
Private Sub btn_Find_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Find.Click
-
Try
-
Dim lsHT(1) As Object
-
Dim lsDT1c As New DataTable
-
lsHT(0) = "1"
-
lsHT(1) = Trim("Name") & "01001"
-
lsDT1c = lsDT1.Copy
-
-
Dim frmFind As New foFIND(lsDT1c, lsHT, lsFINDNAME1)
-
lsFINDNAME1 = lsTEXTBOX(1).Text
-
frmFind.ShowDialog()
-
lsFINDNAME1 = cls1.FindPro
-
If Len(Trim(lsFINDNAME1)) > 0 Then
-
Dim lsFINDKEY(1) As Object
-
lsFINDKEY(0) = "1"
-
lsFINDKEY(1) = Trim(lsFINDNAME1)
-
liCR = cls1.GetRecordPosition(lsDT1, lsKEY, lsFINDKEY)
-
If liCR >= 0 Then
-
DataBindClear()
-
DataBind()
-
DataDisplay()
-
Me.BindingContext(lsDT1).Position = liCR
-
End If
-
End If
-
lsDT1c.Dispose()
-
Catch exp As Exception
-
MsgBox(exp.Message)
-
End Try
-
End Sub
-
-
Private Sub btn_modify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Modify.Click
-
lsMODE1 = "MODIFY"
-
lbl_gsmode1.Text = lsMODE1
-
DataBindClear()
-
DataDisplay()
-
GetTwnReg()
-
lsTEXTBOX(2).Focus()
-
End Sub
-
-
Private Sub btn_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Add.Click
-
lsMODE1 = "ADD"
-
lbl_gsmode1.Text = lsMODE1
-
DataClear()
-
DataBindClear()
-
DataDisplay()
-
GetTwnReg()
-
lsTEXTBOX(1).Focus()
-
End Sub
-
-
Private Sub GetTwnReg()
-
If lsMODE1 = "ADD" Or lsMODE1 = "MODIFY" Then
-
txt_Name.Visible = True
-
txt_Address.Visible = True
-
txt_Phone.Visible = True
-
txt_Code.Visible = True
-
cbo_State.Visible = True
-
Else
-
txt_Name.Visible = False
-
txt_Address.Visible = False
-
txt_Phone.Visible = False
-
txt_Code.Visible = False
-
cbo_State.Visible = False
-
End If
-
End Sub
-
-
Private Sub btn_Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Delete.Click
-
Try
-
lsMODE1 = "DELETE"
-
lbl_gsmode1.Text = lsMODE1
-
liCR = Me.BindingContext(lsDT1).Position
-
liANS = MsgBox("Confirm to delete " & lsDT1.Rows(liCR).Item(lsKEY) & "?", MsgBoxStyle.YesNo, "System Dialog")
-
If liANS = 6 Then
-
lsDT1.Rows(liCR).Delete()
-
lsDA1.Update(lsDS1, lsTABLE1)
-
End If
-
Catch exp As Exception
-
MsgBox(exp.Message)
-
lsDT1.RejectChanges()
-
Exit Sub
-
Catch exp As SqlException
-
MsgBox(exp.Message)
-
lsDT1.RejectChanges()
-
Exit Sub
-
End Try
-
lsMODE1 = "VIEW"
-
lbl_gsmode1.Text = lsMODE1
-
DataDisplay()
-
-
End Sub
-
End Class
2 4720 Plater 7,872
Recognized Expert Expert
Well I would think that the error message woul tell you more, as well as giving you the line number that caused the error.
I will say that you SQL SELECT statement looks like its missing some spaces (like after the FROM, youwould have like FROMmyTableName instead of FROM myTableName)
Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [CODE] [/CODE] tags in future.
MODERATOR
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Professor Frink |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms application that is going to be
used to extract data from a legacy system (VSAM based mainframe file
structure), and output data in pipe-delimited record layouts, multiple record
types per file, one file per chosen client. I have been working on...
|
by: Adam Smith |
last post by:
When executing ExecuteXmlReader() against a table where records are
being inserted, I get:
9/5/2003 8:39:47 AM Transaction (Process ID 66) was deadlocked on lock
resources with another process and has been chosen as the deadlock
victim. Rerun the transaction.
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteXmlReader()
|
by: Craig831 |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms application that is going to be
used to extract data from a legacy system (VSAM based mainframe file
structure), and output data in pipe-delimited record layouts, multiple record
types per file, one file per chosen client. I have been working on...
|
by: James Cooke |
last post by:
Hi all,
I want to catch a duplicate key exception. I do not want to provide that
verbose message from the MSSQL server - I would put a user friendly message
out, like
"The item you have added already exists in the database. Please change
the description and try to save again."
instead of
|
by: Alan Pretre |
last post by:
I have an application installed at a customer site that has been getting a
general network error for a couple of years. I was hoping that .NET 2.0
would clear it up, but unfortunately it didn't. The .NET 2.0 exception does
give a little more info than .NET 1.1 did, but not much.
Can anybody give any pointers about how to track this down? It occurs every
10 hrs around the clock, like clockwork.
I have included the stack trace, but...
| |
by: Jonas |
last post by:
Hi!
I have a general error logging routine that takes a parameter of type
Exception. But if I send in a SqlException, I loose all the Sql-specific
information as the variable is casted to an ordinary Exception. How do I
recast it to its original type without having to hard-code all different
types of exceptions with "typeOf exception Is
System.Data.SqlClient.SqlException" ?
CType(myExp, System.Type(myExp.GetType.FullName))
|
by: Rampa |
last post by:
hello! the problem is always the same but i can't understand why it
happens!! Someone can help me? FIRST QUERY GOES WELL, SECOND BREAK WITH
ERROR why?
Dim connessione As New
SqlClient.SqlConnection("Server=SOSQLSRV01;Initial
Catalog=SO_Bolle;Uid=SO_CattolicaRE;PWD=sogeda")
Dim iddestinatario As Integer
Dim TestoQueryCodicecodicedestinario As String = "SELECT
|
by: Carol |
last post by:
Exception may be thrown in the code inside the try block.
I want to handling the SqlException with State == 1 in a special way,
and for all others I want to use a general way to handle. Which of the
following options is better?
-----------------------------------------------------
Option 1:
try{...}
catch (System.Data.SqlClient.SqlException ex)
{
if (ex.State == 1)
|
by: Pedro Dinis |
last post by:
i have this class library that connects to the database(see appconfig below)
compiling 0 errors but when its running i amhaving this error
An unhandled exception of type 'System.NullReferenceException' occurred in
my_deepot_common.dll Object reference not set to an instance of an obj
int this line
public System.Data.SqlClient.SqlConnection user_connection = new
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |