ODBC Data Reader?
Is the DataReader only for SQLServer or can it be used with ODBC? If so, is
anyone aware of a sample out there? Tag: ReadOnly ComboBox Tag: 81519
Help in calling Oracle Package from aspx page
This is a multi-part message in MIME format.
------=_NextPart_000_001D_01C401B9.CFCC3260
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I'm, trying to call a package from my page to populate a datagrid. I'm =
using an example from the web, but I can't get it to work.
Here is my code:
code in the aspx page:
...
OracleConnection cnnOracle =3D new =
OracleConnection(ConfigurationSettings.AppSettings["ConnectionString"]); =
cnnOracle.Open();
OracleCommand oraCmd =3D new OracleCommand("{call =
PACKPERSON.AllPerson({resultset 10,ssn,fname,lname})}",cnnOracle);=20
oraCmd.CommandType =3D CommandType.StoredProcedure;
DataSet dstPerson =3D new DataSet();
OracleDataAdapter adpPerson =3D new OracleDataAdapter(oraCmd);
adpPerson.Fill(dstPerson);
this.DataGrid1.DataSource=3D dstPerson;
this.DataGrid1.DataBind();
...
When I run my application I get the following error:
ORA-06550: line 1, column 7: PLS-00103: Encountered the symbol "{" when =
expecting
one of the following: begin case declare exit for goto if loop mod null =
pragma raise return select update while with <an identifier>=20
<a double-quoted delimited-identifier> <a bind variable>=20
<< close current delete fetch lock insert open rollback savepoint set =
sql=20
execute commit forall merge <a single-quoted SQL string> pipe=20
Any suggestion are welcome.
Thanks
Garfield
------=_NextPart_000_001D_01C401B9.CFCC3260
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I'm, trying to call a package from my =
page to=20
populate a datagrid. I'm using an example from the web, but I can't =
get it=20
to work.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is my code:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>code in the aspx =
page:<BR>...<BR> =20
OracleConnection cnnOracle =3D new=20
OracleConnection(ConfigurationSettings.AppSettings["ConnectionString"]);&=
nbsp;</FONT></DIV>
<DIV>
<P><FONT face=3DArial size=3D2> =
cnnOracle.Open();<BR> =20
OracleCommand oraCmd =3D new OracleCommand("{call =
PACKPERSON.AllPerson({resultset=20
10,ssn,fname,lname})}",cnnOracle); <BR> =
oraCmd.CommandType =3D=20
CommandType.StoredProcedure;<BR> DataSet dstPerson =3D new=20
DataSet();<BR> OracleDataAdapter adpPerson =3D new=20
OracleDataAdapter(oraCmd);<BR> =20
adpPerson.Fill(dstPerson);<BR> this.DataGrid1.DataSource=3D=20
dstPerson;<BR> this.DataGrid1.DataBind();<BR>...</FONT></P>
<P><FONT face=3DArial size=3D2>When I run my application I get the =
following=20
error:</FONT></P>
<P><FONT face=3DArial size=3D2>ORA-06550: line 1, column 7: PLS-00103: =
Encountered=20
the symbol "{" when expecting<BR> one of the following: begin case =
declare=20
exit for goto if loop mod null <BR>pragma raise return select update =
while with=20
<an identifier> <BR><a double-quoted delimited-identifier> =
<a=20
bind variable> <BR><< close current delete fetch lock insert =
open=20
rollback savepoint set sql <BR>execute commit forall merge <a =
single-quoted=20
SQL string> pipe </FONT></P></DIV>
<DIV><FONT face=3DArial size=3D2>Any suggestion are =
welcome.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>Garfield</FONT></DIV></FONT></DIV></BODY></HTML>
------=_NextPart_000_001D_01C401B9.CFCC3260-- Tag: ReadOnly ComboBox Tag: 81518
ReadXmlSchema into an existing DataTable
Hi.
I'm trying to read xml schema to a dataset that already contains datatable
with the same name as the one in schema file and ReadXmlSchema has no
effect.
This console application in VB.Net demonstrates it:
Module Module1
Sub Main()
WriteSchemaFromNW()
End Sub
Private Sub WriteSchemaFromNW()
Dim connection As SqlClient.SqlConnection
Try
Dim connectionString As String = "integrated security=SSPI;data
source=localhost;persist security info=False;initial catalog=Northwind"
connection = New SqlClient.SqlConnection(connectionString)
Dim command As New SqlClient.SqlCommand("Select * from Orders", connection)
Dim da As New SqlClient.SqlDataAdapter(command)
Dim ds As New DataSet
Dim dt As New DataTable("Orders")
ds.Tables.Add(dt)
da.Fill(dt)
ds.WriteXmlSchema("c:\Orders.xml")
dt = Nothing
Dim ds1 As New DataSet, ds2 As New DataSet
Dim dt1 As New DataTable("Orders")
ds1.Tables.Add(dt1)
ds1.ReadXmlSchema("c:\Orders.xml")
ds2.ReadXmlSchema("c:\Orders.xml")
Console.WriteLine("Reading schema into dataset with existing table")
For Each tbl As DataTable In ds1.Tables
Console.WriteLine(String.Format("Table {0} - number of rows = {1}, number of
columns = {2}", tbl.TableName, tbl.Rows.Count, tbl.Columns.Count))
Next
Console.WriteLine("Reading schema into an empty dataset")
For Each tbl As DataTable In ds2.Tables
Console.WriteLine(String.Format("Table {0} - number of rows = {1}, number of
columns = {2}", tbl.TableName, tbl.Rows.Count, tbl.Columns.Count))
Next
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
If Not connection Is Nothing Then
connection.Dispose()
End If
End Try
End Sub
End Module
Any help is very appreciated.
Thanks a lot
- Predrag. Tag: ReadOnly ComboBox Tag: 81515
Access to SQL 2000
I would like to write a program to convert Access tables to SQL 2000 tables.
I could certainly write a program which collects each field in the access
table and creates a similar field in SQL 2000 and then populates the file,
however I am assuming that XML may offer a solution which would require only
a few statements. Does anyone with XML expertise have an idea of this?
Regards Tag: ReadOnly ComboBox Tag: 81513
storing data locally?
Hi,
in a nutshell, is there a quick and efficient way of storing data from
a database on each user's machine so that a WinForm application can
query/analyze/do whatever it wishes to this local data?
the winform app will never need to interact with the original database
except the first time it is run - to create the local data files on
each user's computer. From then on, each time a user runs the
application, the app would be using the local data.
I thought of saving the data as XML files... but I am concerned about
efficiency. As well, I do not need the files to be viewed through
other mediums (web, excel, etc.).
Actually, I would prefer it if the local files are NOT viewable in
other mediums... only the WinForm application would use the files.
If I am able to query data in these local files using SQL (like
"select myCol From file1.dat") that would be also be a huge plus....
I also thought of loading a DataSet object then serializing it to a
file... any links/advice/help on this? I couldnt really find any
specific examples/white papers on serializing data, but I am still
looking.
Any other suggestions? Thank you. Tag: ReadOnly ComboBox Tag: 81512
Adding a datarow to datatable bounded to listbox. Please help!
Hi,
I have a problem with adding a datarow to datatable that is bounded to
listbox.
Here is what I am trying to accomplish:
1) Connect to access database and select table into dataset (works
fine)
2) Create dataview of that table and bind it to listbox (works fine)
3) Add datarow to datatable containing information from some other
source and the added datarow should automatically be displayed in
listbox (having problem)
4) Update access table with new information...
Here is how I add datarow to my datatable.
drTo = dsStudents.Tables("ToStudents").NewRow()
drTo("SomeColumn") = ...
drTo("SomeColumn2") = ...
dsStudents.Tables("ToStudents").Rows.Add(drTo)
The thing is that datarow is actually gets added to the datatable but
in the listbox it is appears as "blank". Now, if I add a second row
after that, the first row now changes from "blank" to the one with
information (Student's Name). But, now the second row is displayed as
"blank". In other words the number of items that are in listbox are
n-1 (1 is blank so total is n) and the number in datatable is n. So
what do I need to do to get new added row to be displayed properly? I
found a solution, to use this line of code:
dsStudents.Tables("ToStudents").AcceptChanges()
Now this works fine, however, the RowState changes from added to
unmodified and calling Update method of DataAdapter would cause no
rows to be updated since all rows are marked as unmodified.
Is there another way I can get result that I want without using
AcceptChanges() I appreciate your help! Tag: ReadOnly ComboBox Tag: 81511
Common database code for Oracle, SQL Server, MS Access
I am writting an application in VB.Net, as part of programming I realize that depending on what database I connect to Access, SQL Server or Oracle, I have to use a different SQL Query Syntax... and include different type of database libraries in my code
In phase one we want to develop the app on MS Access and later on wants to migrate to Oracle or SQL Server.
>>What do I need to do to write the code in such a way that I don't have to rewrite any code when I migrate the app from MS Access to SQL Server or Oracle? Can I just use ODBC connection all across? Will ODBC work on ACCESS from VB.Net?
Thanks in advance
-Raj Tag: ReadOnly ComboBox Tag: 81510
Performance considerations
Hi all
I am currently designing a program that uses the ado.net.
I have a question..
Which is better? To have your data constraints implemented on the dataset or constraints on the database? Or both
Thanks a million Tag: ReadOnly ComboBox Tag: 81509
ExecuteScalar return decimal instead of int?
Hi
When I use the ExecuteScalar and the sql looks like this "Insert ...; Select
SCOPE_IDENTITY()" I get the return value as decimal - how can I cast it so
it will return an integer? I use .net c#
Thanks Tag: ReadOnly ComboBox Tag: 81505
Looking for asp.net + mssql hosting
Hi,
I have several days looking for good alternatives to host asp.net sites that
uses MsSQL Server.
I found here several good comments about this site :
http://www.webhost4life.com/, and seems very good.
However I found this other, which really overpass the first one, regarding
space and traffic allowance :
http://www.securemate.com
Also, the connection is very fast.
The only things I see webhost is better than securemate is because they have
more components included.
Please, tell me where's the trick ?
Could somebody compare their current hosting provider to this company and
tell what are they missing ?
Thanks in advance, Tag: ReadOnly ComboBox Tag: 81502
Not Enough Storage
We are receiving the following exception quite frequently in our application
and was wondering if anyone could shed some light on this.
Error Description: Not enough storage is available to process this command.
Source: System.Data
Stack Trace: at System.Data.SqlClient.SqlConnection.Open()
This is ASP.NET corporate intranet website connecting to SQL Server using
the Microsoft Data Application Block component. What causes Open() to issue
this exception?
Scott Lorenz Tag: ReadOnly ComboBox Tag: 81499
Installable ISAM error message
This code produces the "Could not find Installable ISAM" error message.
Anybody have any suggestions?
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
strFilePath
strConnectString += "Extended Properties=text;HDR=Yes;FMT=Delimited"
Dim ds As New DataSet
Dim da As New OleDbDataAdapter("SELECT * FROM " & strFileName,
strConnectString)
da.Fill(ds)
I need to fill a dataset from a text file. Tag: ReadOnly ComboBox Tag: 81493
Insert to SQL Server from a text file
I am using vb.net and want to insert data from a .csv file into a table. I
am looking everywhere but am coming up empty. Can someone be so kind as to
post some sample code for me?
Thank you.
Mike B Tag: ReadOnly ComboBox Tag: 81488
textbox databind problem
I have DataSet with two DataTable and DataRelation between them.
I have two DataGrids with master / detail style and additional textbox which
are bind to detail table.
ds.Tables.Add(tableCompany);
ds.Tables.Add(tableBranch);
ds.Relations.Add("Branch",
ds.Tables["Company"].Columns["CompanyID"],
ds.Tables["Branch"].Columns["CompanyID"]);
this.gridCompany.SetDataBinding(ds.Tables["Company"], "");
this.gridBranch.SetDataBinding(ds.Tables["Company"], "Branch");
this.tbCode.DataBindings.Add("Text", ds.Tables["Company"], "Branch.Code");
this.tbStreet.DataBindings.Add("Text", ds.Tables["Company"],
"Branch.Street");
Now if I update textbox tbCode of tbStreet and then click the update button
which updates DT changes back to database nothing happens BUT if I after
updating TextBox click the DG then it will update changes back to DB.
How do I make so that the TextBox will update the DT immediately it loses
focus? Do I need to use some refreshing code on TextBox.Leave event? Or some
additional code on my Update button?
Thanks,
Oka Morikawa Tag: ReadOnly ComboBox Tag: 81486
Object reference not set to an instance of an object
Hi All,
I have an intermittent problem with an SQLDataAdapter.Fill command. Every
now and then the system returns an "Object reference not set to an instance
of an object" right after filling the Address table.
Public Sub GetProfileTables(ByVal strSQL As String)
Dim cnn As New SqlConnection("Server=localhost; Database=myDatabase;
UID=user; PWD=password;")
_profileSet = New DataSet("Profile")
cnn.Open()
'Get the profile tables information
' The SQL statement would be something like SELECT * FROM vwProfile
WHERE profile_key = 1110201
' where the profile key basically is different depending on the
record being viewed.
Dim daProfile As New SqlDataAdapter(strSQL, cnn)
daProfile.Fill(_profileSet, "Profile")
_profileView = _profileSet.Tables("Profile").DefaultView
'Get the profile addresses
strSQL = "select * from address where profile_key = " &
_profileView(0)("profile_key")
daProfile.SelectCommand = New SqlCommand(strSQL, cnn)
daProfile.Fill(_profileSet, "Address")
'Define the parent and child columns
Dim parentCol, childCol As DataColumn
parentCol = _profileSet.Tables("Profile").Columns("profile_key")
childCol = _profileSet.Tables("Address").Columns("profile_key") '
**THIS IS WHERE THE ERROR OCCURS**
'Define the relationship of the data
Dim drProfile As DataRelation
drProfile = New DataRelation("ProfileAddress", parentCol, childCol)
_profileSet.Relations.Add(drProfile)
cnnITT.Close()
End Sub
Any suggestions?
Thanks
Ryan Tag: ReadOnly ComboBox Tag: 81482
Timeout Expired exception
Hi,
I have a question regarding the "Timeout Expired" excetpion.
We have a database server running SQL 2000, and another computer accessing
the database server using ADO.NET (via a CAT 5 cable directly).
Occationally, I get a "Timeout Expired" exception tring to access database
server.
I do notice that the clock on the two computers may be drifted as far away
as 6 minutes. Can this contribute to the timeout exception?
In the sense of robust programming, what should I do in my code to survive
these kind of exceptions?
Thanks,
Guogang Tag: ReadOnly ComboBox Tag: 81479
using xsd and datasets with XmlDataDocument
I have the following xml:
<message>
<envelope>
<body key="" value="" />
</envelope>
</message>
I have associated an xsd to this xml in order to use the
XmlDataDocument and give me the
possibility to access the data through a dataset in the manner below
specified:
DataSet ds = XmlDataDocument.DataSet;
When I try to add an element of type "body" to this xml file, this tag
is added to the node
"message" while I want to add it to the node "envelope".
Here is the code which I use to do this task:
DataRow dr = ds.Tables["body"].NewRow();
dr["key"]=126;
dr["value"]="example";
ds.Tables["body"].Rows.Add(dr);
and here is the resulting xml:
<message>
<envelope>
<body key="" value="" />
</envelope>
<body key="126" value="example" />
</message>
while I want the following result:
<message>
<envelope>
<body key="" value="" />
<body key="126" value="example" />
</envelope>
</message>
Last but not least when I try to get the attribute values of the node
inserted in the xml by
the previous code I don't have any problem even if the xsd doesn't
allow a "body" tag out of
the "envelope" tag. For example:
foreach(DataRow row in ds.Tables["body"].Rows )
{
if (row[0].ToString() == "126")
{
myVariable = row[1].ToString();
break;
}
}
How can I avoid to append the node inserted by code to the
root node using the dataset and its related classes ? How can I insert
the new node
correctly inside the envelope element (always using datasets) ?
Every suggestion will be appreciate,
thanks in advance Tag: ReadOnly ComboBox Tag: 81478
How Deadlock are handled in ADO.NET
Hello everyone,
I want to know how it work in ADO.NET when a DEADLOCK occur and a
victim is choosen?
Is an exception raised?
Thank's
Carl
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com Tag: ReadOnly ComboBox Tag: 81476
How to access .edb files
I need to access the data in a .edb file, which is the type of database used by the Windows System Resource Manager, natively in my C# application. I can't seem to find a data provider that will connect to it, though. Although the WSRM stores the .edb file in a folder called "Jet DB", none of the existing Jet providers will connect to it (the usual Jet extension is .mdb)
Does anyone know how I can access this data? Right now I have to open up the WSRM, manually export the data to a text file, and then work with it from there. It's not a very good permanent solution
Thanks
Jeff Tag: ReadOnly ComboBox Tag: 81467
timout error on server running vb .net routine
I'm getting the following error - not always, only randomly - when I run a
certain routine (the routine is a simple executenonquery and it appears to
complete despite the message) against sql server 2000:
"timout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding"
Anyone have any idea what causes this and how to avoid it?
Thanks for any help.
Bernie Yaeger Tag: ReadOnly ComboBox Tag: 81460
Help with Net Provide for Oracle...
Hello All
I am using the 1.1 framework, and the Microsoft Oracle Provider for .net, and have oracle Client (8.1.7) installed
The problem I am having is that I am querying an Oracle 7.3 Database, which does not support double-bit characters, but upon querying the database, it appears that all varchar2 fields are coming back as kanji or something, whereas dates and ints are returning correctly
I have tried changing the connection string from unicode=true, even unicode=false, and not having it all all, but I still get the same results
Also, I have connected using the typical OLEDB connection, which returns the data correctly, but would prefer the Oracle Provider for .net
Any help would be great. Tag: ReadOnly ComboBox Tag: 81459
ASP update to database, need sample or tutorial
In preparation for an app that will be a simple ASP.NET page with about 40
text boxes I need sample to do the following:
1. Select the current data (done)
2. Bind to the textboxes (done)
3. When user clicks the update button the page will update the data in the
database.
Existing code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.SqlConnection1.Open()
Me.SqlDataAdapter1.Fill(Me.TerrDataSet)
Me.DataBind()
Me.SqlConnection1.Close()
End If
End Sub
The above works and shows the value of the fields in the text boxes.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim picnt As Integer
Me.SqlConnection1.Open()
Try
picnt = Me.SqlDataAdapter1.Update(Me.TerrDataSet)
Catch ex As Exception
Dim s As String = ex.Message
End Try
Me.SqlConnection1.Close()
End Sub
This code shows a count of 0 for the Update??? Tag: ReadOnly ComboBox Tag: 81458
Thanks for everyone's feedback
Looks like I've got a lot of reading to do :
As I understand the concept of Singleton objects, they can only be instantiated once. Then, all other calls to that object rely on that previously created instance. If you have 300 hundred users, and each of them are doing multiple things (i.e. pulling data, executing stored procedures, etc..), and each time some communication to the data layer takes place, it must filter through that ONE instance (the Singleton obj) because IT is set up to be your data access object, then how does this architecture benefit you? Would it not become a bottle-neck due to their being only the one instance of it Tag: ReadOnly ComboBox Tag: 81455
Dataset persistence
Hi
I'm relatively new to .NET technologies and basically I need this information. We would like to persist the data returned from a database and present the user in Excel/?/Customized GUI Application in order to make him to change the data. Finally all the data updated are to committed back in Database. I know data persistence is possible using dataset but can guide some kind of examples/cod
Is it possible to present the persisted data in Excel or I have to build a customized application? Please some links/examples/samples please
I appreciate your assistance
TIA
Holy Tag: ReadOnly ComboBox Tag: 81451
passing comma delimited string in parameterized query
Hello,
I am having a problem with passing a comma delimited string as a parameter
to be used in the IN() clause for a record selection. What I want to do is
select all customer who have a surname that matches one in a specified list,
which I pass in as a parameter to the query. I am working in VS.Net and
through the designer set up a Sql Command object, the following is generated
'SqlCommand1
Me.SqlCommand1.CommandText = "SELECT * FROM Customer WHERE (SurName IN
(@SurNameList))"
Me.SqlCommand1.Connection = Me.SqlConnection1
Me.SqlCommand1.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@SurNameList",
System.Data.SqlDbType.VarChar)).
In my code I set SqlCommand1.Parameters("@SurNameList").Value =
"Murphy,Sullivan,Lyons"
I know there are customers with these surnames in the DB but my datareader
is empty. I also have tried "'Murphy','Sullivan','Lyons'" but no good.
Any suggestions very much appreciated,
Thanks,
Kay. Tag: ReadOnly ComboBox Tag: 81444
Filter Data
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid?
NOTE: I'm reading a txt file into a dataset with 3 columns:
Id, Name, Age
I have this:
code------------------------------------------------------------------------
-----------------------
LerLinha = New StreamReader(LerPath)
dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))
dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")
dsMrc.Tables.Add(dtMrc)
Do
txtLine = LerLinha.ReadLine()
drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)
dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing
Dim strFilter As String
strFilter = "Id=" & FindUser
dsMrc.Tables("Mrc").Select(strFilter)
dgMarcacoes.DataSource = dsMrc
LerLinha.Close()
LerLinha = Nothing
code------------------------------------------------------------------------
-----------------------
What's wrong??????
--
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca Tag: ReadOnly ComboBox Tag: 81437
CommandBuilder generates inproper SQL Statements
Hallo,
The SQL Statements the CommandBuilder creates never work. (Wrong INSERT INTO
...)
To test this I created a new Access DB and a new application.
I used the wizzard in the IDE and here is the result:
---------
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT ID1, Tabelle1, Tabelle2 FROM
Tab1"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO Tab1(Tabelle1, Tabelle2)
VALUES (?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Tabelle1",
System.Data.OleDb.OleDbType.VarChar, 50, "Tabelle1"))
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Tabelle2",
System.Data.OleDb.OleDbType.VarChar, 50, "Tabelle2"))
----------
The problem obviosly is the ? under VALUES.
The CommandBuilder generates the same CommandText. Is the CommandBuilder
worthless? Tag: ReadOnly ComboBox Tag: 81436
Trapping SQL Error Generated In Trigger
I have a .Net 2003 WinForms application. I have a form that uses a SQLDataAdapter along with a Stored procedure to make inserts to a table in my SQL Server 2000 database. The table has an Instead Of Trigger for Inserts that checks a business rule and either raises an error or makes the insert using the data in the Inserted table
When the error is raised in the Trigger, it is not picked up by the SQlDataAdapter. My application procedes like the insert was made, but in actuality the server raised the error and the insert is not made. I also tried placing data in the insert that would pass the business rule but would cause a foreign key constraint violation. In this case the Trigger procedes with the insert using the data in the Inserted table but the insert fails and a foreign key contraint error is raised, but again my DataAdapter does not pick up this error and my application procedes as if the insert was made, even though it was not
Does anyone know of a way to configure the DataAdapter so it will pick up errors either raiesed in a trigger or generated during the execution of a SQL statement in a trigger? The trigger is working fine and I have verified this by entering data directly into my SQL Table, in which case the errors are generated and displayed. Any help would be greatly appreciated. Here is my trigger code:
[code
ALTER Trigger trgHouseholdPrimaryChec
ON tblHousehol
Instead of Inser
A
Declare @Relation varchar(20
Declare @CaseId intege
Set @Relation = (Select Household_Relationship From Inserted
Set @CaseId = (Select Household_CaseId From Inserted
Select Household_Id From tblHousehold Where Household_CaseId = @CaseId And Household_Relationshi
= 'Primary Client
If @@Rowcount > 0 And @Relation = 'Primary Client
Begi
RAISERROR(50001,16,1
en
Els
INSERT INTO [CaseManagement].[dbo].[tblHousehold]([Household_CaseId], [Household_Active],
[Household_FirstName], [Household_LastName], [Household_MiddleName], [Household_SuffixName],
[Household_Relationship], [Household_HomePhone], [Household_WorkPhone], [Household_ContactPhone],
[Household_CellPhone], [Household_DateAdded], [Household_InactiveDate], [Household_MailStreetPo],
[Household_MailAptNum], [Household_MailCity], [Household_MailState], [Household_MailZip], [Household_SSN],
[Household_SecureRoom], [Household_FraudRisk], [Household_EmploymentTraining], [Household_WorkRestrictions],
[Household_WorkLimitations], [Household_MaritalStatus], [Household_DOB], [Household_School],
[Household_Grade], [Household_Felony], [Household_FelonyDetails], [Household_ParoleProbation],
[Household_ParoleProbationOfficer], [Household_ParoleProbationAddress], [Household_ParoleProbationCity],
[Household_ParoleProbationState], [Household_ParoleProbationZip], [Household_ParoleProbationDetails],
[Household_BranchofMilitary], [Household_RankAtDischarge], [Household_MilitaryStartDate],
[Household_MilitaryEndDate], [Household_DischargeType], [Household_Comments], [Household_UpdatedBy],
[Household_UpdatedOn], [Household_CreatedBy], [Household_CreatedOn])SELECT [Household_CaseId]
[Household_Active], [Household_FirstName], [Household_LastName], [Household_MiddleName],
[Household_SuffixName], [Household_Relationship], [Household_HomePhone], [Household_WorkPhone],
[Household_ContactPhone], [Household_CellPhone], [Household_DateAdded], [Household_InactiveDate],
[Household_MailStreetPo], [Household_MailAptNum], [Household_MailCity], [Household_MailState],
[Household_MailZip], [Household_SSN], [Household_SecureRoom], [Household_FraudRisk],
[Household_EmploymentTraining], [Household_WorkRestrictions], [Household_WorkLimitations],
[Household_MaritalStatus], [Household_DOB], [Household_School], [Household_Grade], [Household_Felony],
[Household_FelonyDetails], [Household_ParoleProbation], [Household_ParoleProbationOfficer],
[Household_ParoleProbationAddress], [Household_ParoleProbationCity], [Household_ParoleProbationState],
[Household_ParoleProbationZip], [Household_ParoleProbationDetails], [Household_BranchofMilitary],
[Household_RankAtDischarge], [Household_MilitaryStartDate], [Household_MilitaryEndDate],
[Household_DischargeType], [Household_Comments], [Household_UpdatedBy], [Household_UpdatedOn],
[Household_CreatedBy], [Household_CreatedOn] FROM Inserted
[/code]
All parameters and other properties of the DataAdapter have been set in desing mode. I removed the try-catch block that was trapping for a SQLException to see if that was the problem. Even without the try-catch no unhandled errors occur. Here is my update code:
[code]
Private Sub UpdateDataSet()
Dim dtChangesHousehold As dsHouseholdView.tblHouseholdDataTable = New dsHouseholdView.tblHouseholdDataTable
Me.BindingContext(Me.DsHouseholdView1.tblHousehold).EndCurrentEdit()
dtChangesHousehold = CType(DsHouseholdView1.Tables("tblHousehold").GetChanges(DataRowState.Added Or DataRowState.Modified),dsHouseholdView.tblHouseholdDataTable)
If (Not (dtChangesHousehold) Is Nothing) Then
SqlDataAdapterHousehold.UpdateCommand.Connection = cnn
SqlDataAdapterHousehold.InsertCommand.Connection = cnn
SqlDataAdapterHousehold.Update(dtChangesHousehold)
DsHouseholdView1.Merge(dtChangesHousehold)
DsHouseholdView1.AcceptChanges()
MessageBox.Show("Your updates have been successfuly submitted to the database!", "Database Update Successful!")
Else
MessageBox.Show("There are no updates to the Case data to submit!")
Exit Sub
End If
End Sub
[/code] Tag: ReadOnly ComboBox Tag: 81432
ForeignKeyConstraint & GetChanges
I've noticed that if I have an update in a child table with a
foreignKeyConstraint that the parent table related row is not brought
over when .GetChanges is called, thus breaking the
foreignKeyConstraint. A full data relation with fix the issue but
other than this scenario I will not make use of the data relation and
was wondering if there was a to get the parent row in the table before
I call get changes. I tried the ImportRow function to get the parent
row into the dataset holding changes and then running
ds.Merge(otherDS.GetChanges) but it still breaks the
ForeignKeyConstraint. Any other ideas, or is the data relation the
only way to go?
Thanks,
AJL Tag: ReadOnly ComboBox Tag: 81430
quotes into SQL query
I'm writing a class that crawls through a removable media retrieving file
info (who didn't make one yet?) and storing in an Access mdb.
OleDbCommand fails when the file name contains quotes as in
My friend's pictures.zip
When building the SQL INSERT query, I tried putting \" before and after as
suggested in a MS KB but it didn't work. I'm almost going to escape the
entire file name a la http...
Should I use stored procs and pass the file name as a parameter? Would it
avoid escaping the file name?
Many thanks
Henrique
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.608 / Virus Database: 388 - Release Date: 3/3/2004 Tag: ReadOnly ComboBox Tag: 81429
ANN: Data Access Objects 1.3 released (GNU LGPL)
Hi all
I'm pleased to announce the latest release of my Data Access Objects.
The library was released under the LGPL which means that you can use it
in commercial applications.
At a glance:
- Vendor independent relational data access layer
- Automation through Persistence Containers that operate upon the data
access layer
- Object-relational mapping through a Visual Studio add-in (XML files)
or custom attributes
Visit the project site @ http://dao.sourceforge.net
Regards
Philipp Tag: ReadOnly ComboBox Tag: 81428
deleting rows from a table that has a composite primary key
hi all
i am new to the c# language . i would like to know that how would you delete a row on the basis of its primary key in a table which has composite primary key
And also tell me how would you delete rows from a table which is inter-related to the other one , i mean if u have the foreign key in the other tabel and u want to delete the row in the table which has the primary key then how wud u delete the both
Is it that u have to delete in the primary key table and the foreign key table separatel
Thanx in Advanc Tag: ReadOnly ComboBox Tag: 81427
Multiple statements with one command using System.Data.OracleClient
I am writing a dataaccess layer in which am building my SQL statements
dynamically. Currently i am using the Oracle classes in
System.Data.OracleClient but executing muliple statements does not seem to
work. What i try to do is something like
INSERT INTO A (.. ) VALUES (:a ); SELECT * FROM A WHERE .. = :a; INSERT INTO
B ( ... ) VALUES (:a)
so I have one row in my dataset and want to split this row out into multiple
tables reading back the record in between to get the values that are updated
using triggers.
This is no problem using the SqlClient classes but the Oracle implementation
does not seem to support this. It seems to be a limitation in the Microsoft
implemetation. Did anyone try to get around this problem using anonymous
procedures?
So for instance
BEGIN
UPDATE A SET "a" = :a WHERE (a = :OriginalA);
SELECT * FROM A WHERE (a = :OriginalA);
END;
results in the following error "ORA-06550: ... :PLS-00428: In this
SELECT-statement an INTO-clausule must be used. ORA-06550: ... PL/SQL: SQL
Statement ignored.". Does anybody have a solution for this problem?
Has anyone tried using mulitple statements while making use of ODP.NET (or
alternatively with the DataDirect
Data Provider?)
Any help would be greately appreciated.
R. van Poelgeest (just remove the spaces to get my email address)
@ metaobjects.net Tag: ReadOnly ComboBox Tag: 81416
Error Creating TXT File
Private Sub find_file(ByVal strFile)
Dim Path As String
Dim NewFile As StreamWriter
strFile = "Extern\" & strFile
Path = Server.MapPath(strFile)
If Not File.Exists(Path ) Then
NewFile = File.CreateText(Path )
NewFile .Close()
End If
End Sub
I have this to find (and create, if not found) a file. The problem is that
it's not working.
It gives me an error like this:
Access to the path "c:\(all path)\Extern\novo.txt" is denied
I think that I have to set permissions, but where??? I already put the Read
an Write Permissions for that application in IIS, and in the right path too.
How can I set this up?
It's missing anything?
--
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca Tag: ReadOnly ComboBox Tag: 81411
Could not add to Oracle DB with dynamic SQL
Hi all,
I want to use dynamic SQL to add a new dataset to an existing Oracle
Table. The table is 'CONTENTTYPE' and contains only 1 field named
'CONTENTTYPE' which is Char(100).
When I create the SQL-String manually' (see example below, for
'boolDynamicSQL = False') everything works fine and the new value is
added.
But when I try to use Dynamic SQL it always returns an error:
ORA-01036: Variablenname/-nummer ungültig
(= ORA-01036: Variable name /-number invalid)
I could not find any typing error, and the manual SQL-String works
fine :-( I've searched lots of internet sites but without access. Also
my 'ASP.NET Codebook' states it should be working this way...
Anyone any ideas? Could this be caused by single / double quotes? I
did not find a setting in Visual Studio.NET to define which quotes
.NET should use for the dynamic SQL. But when I replace the single
quotes in the manual SQL string with double quotes, it returns
'ORA-00984: column not allowed here ', so not exactly the same error
message. (By the way, one time error message is english, and in other
case it's german. Might this be a hint?)
Thanks in advance!!
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
REM First check whether Application name is entered
Dim cnnORA As OracleConnection
Dim comORA As OracleCommand
Dim DR As DataRow
Dim dtContentType As DataTable
Dim ds As DataSet
Dim sqlCommand As String
Dim sqlInsertCommand As String
Dim boolDynamicSQL As Boolean
Dim da As OracleDataAdapter
Dim boolUpdate As Boolean
'Added for checking Dynamic SQL
boolDynamicSQL = True
If txtContentType.Text = "" Then
boolUpdate = False
ASPNET_MsgBox("You have to enter a Content Type!")
Else
REM Check whether this application name already exists
cnnORA = New OracleConnection(Oracle_Connection_String)
cnnORA.Open()
comORA = New OracleCommand
comORA.Connection = cnnORA
ds = New DataSet
sqlCommand = "SELECT CONTENTTYPE FROM CONTENTTYPE"
comORA.CommandText = sqlCommand
da = New OracleDataAdapter(sqlCommand, cnnORA)
da.Fill(ds, "CONTENTTYPE")
dtContentType = ds.Tables("CONTENTTYPE")
boolUpdate = True
For Each DR In dtContentType.Rows
If txtContentType.Text.ToUpper = _
(Convert.ToString(DR.Item("CONTENTTYPE")).ToUpper)
Then
boolUpdate = False
Exit For
End If
Next
If boolUpdate Then
REM Add new data to database
If boolDynamicSQL Then
sqlInsertCommand = "INSERT INTO CONTENTTYPE (" & _
"CONTENTTYPE) VALUES (@CTYPE)"
Else
sqlInsertCommand = "INSERT INTO CONTENTTYPE (" & _
"CONTENTTYPE) VALUES ("
End If
Dim comInsert As New OracleCommand
comInsert.Connection = cnnORA
comInsert.CommandText = sqlInsertCommand
DR = dtContentType.NewRow()
DR("CONTENTTYPE") = txtContentType.Text
For Each objColumn As DataColumn In
dtContentType.Columns
If boolDynamicSQL Then
Dim param As New OracleParameter
param.OracleType = OracleType.VarChar
param.Direction = ParameterDirection.Input
param.Value = "value"
param.ParameterName = "@CONTENTTYPE"
param.DbType = DbType.AnsiString
comInsert.Parameters.Add(param)
'ORA-01036: Variablenname/-nummer ungültig
Else
sqlCommand =
Convert.ToString(DR(objColumn.ColumnName))
sqlInsertCommand = sqlInsertCommand & _
"'" & sqlCommand & "', "
'Mit Double Quotes:
'ORA-00984: column not allowed here
End If
Next
If Not boolDynamicSQL Then
sqlInsertCommand = Left$(sqlInsertCommand,
Len(sqlInsertCommand) - 2) & ")"
comInsert.CommandText = sqlInsertCommand
End If
Try
comInsert.ExecuteNonQuery()
Catch ex As Exception
LblResponse.Text = ex.Message
End Try
Else
ASPNET_MsgBox("ContentType already exists. Please
choose another name " & _
"or update existing data.")
End If
End If
cnnORA.Close()
End Sub Tag: ReadOnly ComboBox Tag: 81410
AS400 invalid token
Ji, i've a simple but strange problem. I must connect to an AS400 from a window form in C#. I use the Data Access of IBM as OLE DB driver and it works good but not with a library calle §DATAACCOUNT. The error sais "Token error" . Could someone tell me how coding the character '§' to send it to AS400 ?
Thanks in advance Tag: ReadOnly ComboBox Tag: 81406
How do I query a dataset?
Hello,
I get how to populate a dataset by querying a database server... but once
I've populated my dataset, say with several related tables, how can I then
select records from the dataset copy of data using SQL statements instead of
the database server itself?
In some cases I'd say this is preferable to hitting the database server
everytime a subset of data needs to be retrieved. Only suitable for small
amounts of static data of course.
As an example if I have a populated table of employee data in a dataset and
I want to populate a temp table with only those records where employee age >
60..... am I limited to filters or can I use SQL statements (which would
then mean no extra code if I decided to point back at the database server
instead of the dataset itself)....?
Hope this makes sense to you guys... cheers Tag: ReadOnly ComboBox Tag: 81390
INSERT a datetime using convert
Hallo
I have an SQLCE database into which I want to insert a datetim
INSERT INTO ADR_ADDRESS (Last_Edited) VALUES ( Convert('01-FEB-2004 11:12:22','dd-mon-yyyy hh:mi:si')
The table was defined wit
CREATE TABLE ADR_ADDRESS (
Address_ID integer Primary Key NOT NULL
,Last_Edited datetime
Unfortunately this does not work, can anyone see what is wrong
Thanks..
Nigel.. Tag: ReadOnly ComboBox Tag: 81388
DataSet.Update on related tables.
Hi all.
Could anyone help me with the following "common" chalenge?
I have 2 simple tables. Customers and Zipcodes.
Customer:
CustomerID, CustomerNr, CustomerName, ZipID
ZipCodes:
ZipID, ZipCode, ZipText
I use the ZipID in the Customer table so if it changes I can change it for
all Customers with that ID. Everey time I show this data in a grid I JOIN to
the ZipID and shows the ZipCode to the users. That works OK.
What I want to do i to use a dataset connected to a datagrid where the user
kan massupdate zipcodes. As you know the user don't know the ZipID that I
need to update the customer field with. He just want to change the ZipCode
on all the customers and push Update. I need to find the corresponding ZipID
and fill that into the corresponding Customer. Is there anyway this can be
incorporated into the dataset so I don't have to check and test and lookup
ZipID's. Mabe with some hidden columns or something.
Short Version:
When the user changes ZipCode in the datagrid I want to save the
corresponding ZipID on that Customer.
I would thing this scenario is rather common but....
I uses stored prosedures to fill and update all data in the database so I
guess I could handle it there based on the ZipCode, but if there are
anything within .NET that handles this I would like to use it.
Thanks a lott all.
-gh Tag: ReadOnly ComboBox Tag: 81386
Dataset From Textfile question
I have created at Dataset from an OleDB connected text file using schema.ini
and so forth, so far no problem, now what I need to do is take the data from
that dataset and update records in another database, (SQL Server) which has
a table that contains the same key as I used in the text file.
I have been able to walk through the first dataset and issue update commands
to the other database one at a time, but I can't help feeling there has to
be an easier way to do this.
I am trying to avoid walking through either the file with file IO commands
or the dataset one row at a time in favor of a batch operation. The data in
the text file will always be used to update records that exist in the target
SQL Server database, never to insert a new row.
Any suggestions? I am writing this as a Winforms app in VB.Net with 1.1
Framework.
Thanks in advance.
Bob Porter Tag: ReadOnly ComboBox Tag: 81382
Oracle stored procedure with db link doesn't work from C#?
Hi
I am calling an Oracle stored procedure which has no input or output parameters, and only does an insert to a table on a remote Oracle server, like this
PROCEDURE Joe_test I
BEGI
insert into leslie@acc_db2 values ('insert')
commit
END
When I call it from C# using System.Data.OracleClient, I get the exception
ORA-02041: client database did not begin a transactio
ORA-06512: at "OPS$JOE.JOE_TEST", line
ORA-06512: at line
If I change it to insert into a local table instead of a remote one, it works. If I run it as is from SQL/Plus, it works. It only fails when I run it from .NET with System.Data.OracleCommand.ExecuteNonQuery()
I have tried using "enlist=false" in the database connect string. This actually seems to solve the problem if I use ODP instead of System.Data.OracleClient, but has no effect with the latter. I don't have a good understanding of what it does other than changing the default handling of distributed transactions. System.Data.OracleClient is supposed to handle distributed transactions
I would appreciate any help or suggestions! Tag: ReadOnly ComboBox Tag: 81376
paging with related records
I'm trying to implement paging in a windows form application on about 50
thousand records the problem is I have related records, which is another 20
thousand. I've searched with google and only found paging but with none
related data.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpagingthroughqueryresult.asp
Right now I can only think of one solution where I populate the related data
by hitting the database after loading the paged data of the first table?
Any other ideas? Tag: ReadOnly ComboBox Tag: 81373
DataAdapter.Update - batch or round trips?
Hi - I've seen several clues to this but I wonder if any experts can
definitively confirm ......
Does the DataAdapter.Update method pass all updated datarows to the
database for some kind of batch process with multiple calls to the
update command but only one open and close of the connection, or does
it do multiple round trips to the database and multiple connection
open/closes, one for each updated datarow?
(My specific interest is in the OracleDataAdapter but I'm guessing the
answer applies to all DB providers).
Thanks for any responses. Tag: ReadOnly ComboBox Tag: 81367
Update query not working
Hi
I have wrote a stored proc (Sproc) to update one of my sqlserver tables. This is what the query looks like
ALTER PROCEDURE dbo.UpdMea
(@NewName nvarchar(50)
@NewCost Money
@MealType varchar(50)
AS UPDATE dbo.Men
SET Meal_Type = @NewName, Meal_Cost = @NewCos
WHERE (Meal_Type = @MealType
I have a combobox that contains a list of meals. When the value is changed a sproc is fired aginst my DB that retrieve the Meal Name and Price based on what is selected in the combobox. The results of this query are then binded to 2 textboxes. The user can then update the values in the textboxes and click the Save button to propogate the changes back to the database
The problem i have is the changes do not seem to appear in my database and no message is displayed showing me a possible error. Can anyone see if i am missing anything in the onclick event code for my save button.....
If MsgBox("Are you sure you want to save your updates?", MsgBoxStyle.OKCancel Or MsgBoxStyle.Question, "Save?") = MsgBoxResult.OK The
Dim cmdUpdMeal As New SqlCommand("UpdMeal", Conn
cmdUpdMeal.CommandType = CommandType.StoredProcedur
cmdUpdMeal.Parameters.Add("@NewName", TextBox1.Text
cmdUpdMeal.Parameters.Add("@NewCost", Convert.ToDecimal(TextBox2.Text)
cmdUpdMeal.Parameters.Add("@MealType",
CBoxEditMealName.SelectedText.ToString
Tr
Conn.Open(
cmdUpdMeal.ExecuteNonQuery(
Catch x As Exceptio
MsgBox(x.Message
Finall
Conn.Close(
End Tr
End If Tag: ReadOnly ComboBox Tag: 81364
Help - System.Data.DataTable.InsertRow() throws ArgumentOutOfRangeException
I have a C# program that works one time and fails the next on my deployment
test system. It does not fail on my development system. The deployment
uses the installation procedure created by Visual Studio 2003. The
deployment is installing the .NET Framework ver 1.1, MSDE 2000, MDAC 2.7,
and my application. I am assuming (bad thing to do) that the install is
working, because the application works every so often.
In all cases I am adding a records to a database. In both instances it is
to an empty database and the data being added is the same. When the windows
program fails the error is always an ArgumentOutOfRangeException on the same
row add. The output from my try-catch code is:
ArgumentOutOfRangeException: System.ArgumentOutOfRangeException: Index was
out of range. Must be non-negative and less than the size of the
collection.
Parameter name: index
at System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32
pos)
at System.Data.DataRowCollection.Add(DataRow row)
at WinMCDB.gdsrvmntDataTable.AddgdsrvmntRow(gdsrvmntRow row)
at MCLoader.Form1.AddGdsrvmnt(String monumnt_id, Int32 date_adj, Double
latitude, Double longitude, Double adj_elev, Double geoid_ht, Double
ellips_ht, String localCoordinateSystem)
ParamName: index, Value: null
Does anybody know why the System.Data.DataTable.InsertRow(DataRow row, Int32
proposedID, Int32 pos) method index is null? Or how I can debug this issue
with a System.Data.DataTable method InsertRow.
Jim Tag: ReadOnly ComboBox Tag: 81363
Multiple Database Datasets Help
I have a case where I am creating a dataset from one database, then I want
to issue a series of updates to another database to update data based on a
common key between the two tables in two separate databases. eg
Database1.Table1
key column2 column3 ....
1232 My Prod 1234.00
Database2.Table1 (To be updated with data from the first table, key already
exists. No inserts allowed, just updates.
key column2 column3
1232 null null
So what is the best approach to this? Create 2 datasets, 1 dataset with a
datatable object from each connection, or just brute force update statements
to the second database while walking through the first dataset? I am
working in VB.NET 2003 and am not very familiar with C# so any examples in
VB.NET would be helpful. Tag: ReadOnly ComboBox Tag: 81359
SqlDataAdapter Not Catching SQL Exceptions
I have a SqlDataAdapter that is not picking up Sql exceptions from the SQL Server database such as foreign key constrain violations. When I call the update method of the dataadapter for either inserts or updates, it just fails silently. If I do the update directly from the SQL table the errors are being generated by the server. The ContinueUpdateOnError property for my adapter is set to false. The adapter was picking up SQL exceptions just fine earlier, so I must have changed something by accident. I have another adapter in my project that is picking up exceptions just fine, so it is not of application wide scope
Does anyone have any idea what might be causing this behavior? Any help would be greatly appreciated. Tag: ReadOnly ComboBox Tag: 81354
ID of a newly created record
Hi,
I'm trying to get the ID of a newly created record into a variable, so I can
display it in a Label or something after being created. I know you can use
@@identity in the sql statement, but I just can't seem to get it to go.
Any help appreciated,
Glyn Williams
Here is my code:-
Public Sub addBike(Sender As Object, E As EventArgs)
Dim myCommand As new SqlCommand()
Dim myConnection As New SqlConnection
("server=Tron;database=sellmybike;Integrated Security=SSPI")
myCommand.Connection = myConnection
'Define insert command
myCommand.CommandText="INSERT INTO Details
(PostDate,Name,Town,County,Seller,Email,Tel,Make,Model,ManYear,Mileage,Price
,Details) VALUES (
@PostDate,@Name,@Town,@County,@Seller,@Email,@Tel,@Make,@Model,@ManYear,@Mil
eage,@Price,@Details)"
myCommand.Parameters.Add ("@PostDate", Now())
myCommand.Parameters.Add ("@Name", msgName.Value)
myCommand.Parameters.Add ("@Town", msgTown.Value)
myCommand.Parameters.Add ("@County", msgCounty.Value)
myCommand.Parameters.Add ("@Seller", msgSeller.Value)
myCommand.Parameters.Add ("@Email", msgEmail.Value)
myCommand.Parameters.Add ("@Tel", msgTel.Value)
myCommand.Parameters.Add ("@Make", msgMake.Value)
myCommand.Parameters.Add ("@Model", msgModel.Value)
myCommand.Parameters.Add ("@ManYear", msgManYear.Value)
myCommand.Parameters.Add ("@Mileage", msgMileage.Value)
myCommand.Parameters.Add ("@Price", msgPrice.Value)
myCommand.Parameters.Add ("@Details", msgDetails.Value)
myCommand.Connection.Open()
'update the tape
myCommand.ExecuteNonQuery()
'Im sure some code must go here and in the sql statement
myCommand.Connection.Close()
End Sub Tag: ReadOnly ComboBox Tag: 81353
Hi to all
How can I make a ComboBox readonly ?
Enabled = false and DropDownStyle = DropDwnList
are not solutions for me.
What about trapping the KeyEvents and cancelling them...
"Dan" <dan@news.com> wrote in message
news:O$ZrxqbAEHA.2216@TK2MSFTNGP10.phx.gbl...
> Hi to all
>
> How can I make a ComboBox readonly ?
> Enabled = false and DropDownStyle = DropDwnList
> are not solutions for me.
>
> Thank you
> Dan
>
>
Thank you for your answer.
My problem is how to stop dropdown with mouse click if DropDownStyle =
DropDwnList
and Enabled = true ?
Dan
"William Ryan eMVP" <bill@NoSp4m.devbuzz.com> wrote in message
news:uILvqxbAEHA.2292@TK2MSFTNGP12.phx.gbl...
> What about trapping the KeyEvents and cancelling them...
> "Dan" <dan@news.com> wrote in message
> news:O$ZrxqbAEHA.2216@TK2MSFTNGP10.phx.gbl...
> > Hi to all
> >
> > How can I make a ComboBox readonly ?
> > Enabled = false and DropDownStyle = DropDwnList
> > are not solutions for me.
> >
> > Thank you
> > Dan
> >
> >
>
>
You have to script client side... (I think)
"Dan" <dan@news.com> a écrit dans le message de news:
#DNAV3dAEHA.916@TK2MSFTNGP10.phx.gbl...
> Thank you for your answer.
> My problem is how to stop dropdown with mouse click if DropDownStyle =
> DropDwnList
> and Enabled = true ?
>
> Dan
>
> "William Ryan eMVP" <bill@NoSp4m.devbuzz.com> wrote in message
> news:uILvqxbAEHA.2292@TK2MSFTNGP12.phx.gbl...
> > What about trapping the KeyEvents and cancelling them...
> > "Dan" <dan@news.com> wrote in message
> > news:O$ZrxqbAEHA.2216@TK2MSFTNGP10.phx.gbl...
> > > Hi to all
> > >
> > > How can I make a ComboBox readonly ?
> > > Enabled = false and DropDownStyle = DropDwnList
> > > are not solutions for me.
> > >
> > > Thank you
> > > Dan
> > >
> > >
> >
> >
>
>