Help please
Hi all,
I want to bind a Datagrid to Sqlcommand, below is my code
SqlConnection cn = new SqlConnection("Server=winnt;user id =sa;initial
catalog =Northwind");
cn.Open();
SqlCommand cmd = new SqlCommand("select * from employees");
cmd.Connection = cn;
dr = cmd.executereader()
Datagrid1.datasource = dr
Can we bind Datagrid to a command directly or to Data Reader without using
dataAdaptaor ?
TIA,
Gary Tag: prb with generated dataform and null values Tag: 68262
Run-time error: SQL Server does not exist or access denied
I attempt to connect ASP.NET application with SQL Server using ADO.NET. I
just open a connection, and it had run-time error in line 34: cn.open():
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: SQL Server does not
exist or access denied.
Source Error:
Line 32: Dim connectionString As String = "Data Source=(local);
Initial Catalog=mydatabase"
Line 33: Dim cn As New SqlConnection(connectionString)
Line 34: cn.Open()
Line 35: Response.Write(cn.ConnectionString & "," &
txtBoxUserName.Text)
Line 36: 'Debug.WriteLine(cn.ConnectionString)
any ideas?? Thanks! Tag: prb with generated dataform and null values Tag: 68261
programming books
I have several programming books for sale at very reasonable prices.
http://cgi6.ebay.com/ws/eBayISAPI.dll?ViewSellersOtherItems&userid=bohemianatlarge&include=0&since=-1&sort=3&rows=50 Tag: prb with generated dataform and null values Tag: 68259
OLEDB or ODBC drivers for Sybase SQL Anywhere 5
Hi,
I know this is probably not the most accurate newsgroup to ask this, but I
already asked in the sybase forums.
Does anyone know where I can download connection drivers or the SQL Anywhere
5 software to connect through OLEDB o ODBC?
I developed a VB.net application using the SQL Anywhere 9 oledb drivers, and
now during deployment those drivers don't connect to the version 5 server.
please help,
Gustavo De la Espriella Tag: prb with generated dataform and null values Tag: 68255
ComboBox DataBinding examples ?
This is not a question. Just an observation I need to share.
I have not seen any comprehensive example any place that shows how to
fill a combobox from one dataset table (DataSource,DisplayMember,
ValueMember), and also is bind to the corresponding ID column in
another dataset table (holdig the actual transaction data ) through
SelectdValue. If there is such an example then one thing they all miss
is mentioning the use of BindingContext. I had been banging my head
against this for long . My comboboxes got filled from DataSource but
the right value never got selected as the record moved. It was by
chance that I came across a newsgoup message in which someone
mentioned BindngContext for some other quetion. then I used
"MyComboBox.BindingContext = this.BindingContext ;" and it worked fine
I am particulary referring to the example at :
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsData.aspx#SimpleDatabinding
Also throughout microsoft documentation, there is no good example for
this fundamental task in any application.
If anybody knows any good links then let me know. thanks
Aamir Tag: prb with generated dataform and null values Tag: 68251
Recommendations for connecting to mySql using mono
Has anyone had experience
hooking up a c#/linux
application to a mySql
database using mono. Tag: prb with generated dataform and null values Tag: 68250
Multiple Table - Update, Modify, Delete
Up till now I have used the VS Wizard to generate my update statments for my
vb.net windows apps. I had only updated one table at a time so everything
was fine.
Now I am in a situation where i need to do a multiple table(2) query and be
able to add, remove , update. Either that or repeat all the columns of the
one in the other table and update both all the time. I just think that is
probably not the way to go. The two tables share a "job number" and a
"jobshipto" in common. The big difference is one has the items for the job
the other has the addresses and vital statistics and such.
To be honest I am not sure where to begin.
If there is a online tutorial about this I would be greatful.
I am deaing with an access database. Tag: prb with generated dataform and null values Tag: 68240
Writing a generic DAL
I have done this with some success. Updates work generically, deletes work
generically, all using DataAdapter and passing DataSet Changes to one
method.
My problem is getting Inserts to work generically. The issue here in Output
parameters. How do I flag a datatable or something else coming in with the
DataSet that when the Datatable contains an Added Row and its looping
through the insert code, building input parameters it also needs to build an
output param and here are all the values needed for the new param
constructor?
Currently, I build all the Insert\Update command parameters in the
RowUpdating event like this:
Dim col As DataColumn
Dim drw As DataRow = e.Row
Dim myParam As SqlParameter
Select Case e.StatementType
Case StatementType.Update
For Each col In drw.Table.Columns
Try
' check the original row against the current row
to see if they are different
If Not (drw(col,
DataRowVersion.Current).Equals(drw(col, DataRowVersion.Original))) Then
' build a parameter for the changed column
myParam = New SqlParameter("@" &
col.ColumnName, drw.Item(col).ToString)
e.Command.Parameters.Add(myParam)
End If
Catch ex As Exception
Throw New Exception("Exception occurred in " &
className & ".OnRowUpdating Event. Column: " & col.ColumnName & ". " _
& ex.message)
End Try
Next
Case StatementType.Delete
For Each colName As String In PrimaryKeys
myParam = New SqlParameter("@" & colName, drw.Item(col,
DataRowVersion.Original).ToString)
e.Command.Parameters.Add(myParam)
Next
Case StatementType.Insert
For Each col In drw.Table.Columns
Try
' build output params
If col.ColumnName = "names_id" Then
myParam = New SqlParameter("@newid",
SqlDbType.VarChar, _
6,
ParameterDirection.Output, _
False, CType(0,
Byte), CType(0, Byte), _
"names_id",
DataRowVersion.Current, _
Nothing)
e.Command.Parameters.Add(myParam)
ElseIf col.ColumnName = "control" Then
myParam = New SqlParameter("@ncontrol",
SqlDbType.VarChar, _
6,
ParameterDirection.Output, _
False, CType(0,
Byte), CType(0, Byte), _
"control",
DataRowVersion.Current, _
Nothing)
e.Command.Parameters.Add(myParam)
Else
myParam = New SqlParameter("@" &
col.ColumnName.Remove(0, col.ColumnName.IndexOf("_") + 1),
drw.Item(col).ToString)
e.Command.Parameters.Add(myParam)
End If
Catch ex As Exception
End Try
Next
End Select
So, as you can see, the Insert has hard code for the output params. I want
to get rid of this so I can send any DataTable insert through this
eventhandler. Currently, it only supports 2 of my Datatables, one with
'control' as the PK and one with 'names_id' as the PK. Tag: prb with generated dataform and null values Tag: 68239
Bizarre OracleClient behavior
Hello. I'm having strange problems with System.Data.OracleClient.
This is the managed oracle data provider in the 1.1 framework. We've
used this assembly on a number of projects and have had no problems.
The latest project is an extremely simple asp.net project. Here's the
code:
try {
string source = "User ID=cbk;Password=blabla;Data Source=cbk;";
OracleConnection mConn = new OracleConnection();
mConn.ConnectionString = source;
mConn.Open();
}
catch(Exception e)
{
log("there was an oracle error: " + e.ToString());
}
Couldn't be easier right? At either the open, or when setting the
connect string, I get this error:
An unhandled exception of type "System.ArgumentOutOfRangeException"
occurred in Unknown Module. Additional Information: Length cannot be
less than zero.
This code is in a try/catch block and the catch does not catch it!
Breaking tells you nothing because there's no source. It doesn't seem
to matter which constructor I use. I can pass in the connect string
any way and get the same behavior. This code works on other machines.
If I compile it on my machine and install it elsewhere, it works. On
my machine, this code works in other projects. I've rebuilt the
project with no affect.
This is really looking to me like a bug in the assembly. Any ideas?
brian Tag: prb with generated dataform and null values Tag: 68238
Howto: Add a CheckBox column to bound WinForms DataGrid
After running a query and binding the data to a DataGrid, I want to add a
Checkbox column ("i.e., Delete/Edit/etc") -
I've seen Asp.Net examples but I'm looking for a WinForms (C#) example.
TIA Tag: prb with generated dataform and null values Tag: 68233
How do you use OleDbLiteral
I am trying to understand how you use OleDbLiteral in code.
I can't find a single code example in the .net reference or through google.
I've looked at three books. One didn't mention it, one has it in the index
but not the text, and one says in the text that it is outside the scope of
the book!
Any Microsoft people (or anyone else) out there who can explain the usage of
this crucial enumeration? How do you get from the enumeration symbols to the
values that they represent?
Tom Tag: prb with generated dataform and null values Tag: 68227
David Sceppa...if you are listening...Update question
First, the book is awesome. Started reading it Monday, finished it last
night. I've done some writing for (formerly) Wrox, so I knows it is tough
to do.
Now, the gory stuff.
We have a strange case I am wondering how to handle with cascading updates.
We have a parent table, call it names (members), and a child table, call it
addr (addresses). Names can have 0 to many types of addresses (Home,
Office, Special, Temporary). The names table has a field for each address:
names.haddr for home address, names.taddr for temp address, names.faddr for
office address, etc.
These fields store a control number that links to the address table. This
control number is the PK for the address table.
Our select returns the names record and any address records in separate
resultsets. @indexname and @id are input parameter to the sproc (sent from a
search screen on the client):
--names
SELECT <these columns>
FROM dbo.names n
WHERE
n.indexname > @indexname
OR
(n.indexname = @indexname AND n.id >= @names_id)
ORDER BY n.indexname, n.id;
--temp address
SELECT TOP 10
atemp.control, atemp.addr1, atemp.addr2 ,atemp.city, atemp.zip,
atemp.phone, atemp.fax , atemp.pobzip, atemp.fc, atemp.st
FROM dbo.names n LEFT JOIN dbo.addr atemp on n.taddr = atemp.control
WHERE
n.indexname > @indexname
OR
(n.indexname = @indexname AND n.id >= @names_id)
ORDER BY n.indexname, n.id
-- home address
SELECT TOP 10
ah.addr1, ah.addr2 , ah.city , ah.zip, ah.phone, ah.fax , ah.pobzip,
ah.control, ah.fc, ah.st
FROM dbo.names n LEFT JOIN dbo.addr ah on n.haddr = ah.control
WHERE
n.indexname > @indexname
OR
(n.indexname = @indexname AND n.id >= @names_id)
ORDER BY n.indexname, n.id;
etc for the remaining possible address
The client creates a DataRelation between the names address fields and each
address DataTable control field. There are 5 DataRelations in all, meaning
there are 5 address DataTables and one names Datatable.
So, on the client, names is the parent and each addr DataTable is a child (5
DataRelations). This works perfect, DataBinding is happy.
Here is the issue. Control is the PK for the addr table in sql server.
Control links to the individual names.haddr. names.taddr, etc fields in the
names table.
This field gets populated from a 'next available control number table in sql
server on an address insert. Kinda like autoincrement accept we supply the
value ourselves.
After doing the insert into the addr table, we need to update the names
record (haddr, taddr, etc) fields. So, on the update the addr is
kinda\sorta the parent and names is kinda\sort the child, if we want
cascading to work. Problem is, the constraint is set up the other way on
the client (in the schema) so navigation works on the client.
Anyway to make this work? Tag: prb with generated dataform and null values Tag: 68219
Send Connection Instructions to SQL Server
I assume that I can send the statement 'SET ANSI WARNINGS OFF' to SQL with
the sqlcommand object's method ExecuteNonQuery(), but can it (and other
behavioral statements) be sent alternatively?
Reason I ask is I'm executing stored procedures and simply didn't want to
pass behavioral statements this way. Is there any property like
_cmdSqlServer.Behavior = ...
thanks,
Eric Tag: prb with generated dataform and null values Tag: 68214
Databinding Question
Hi,
In my app I am trying to bind a dataset to a combo box and I am having some
trouble. In the combo box it shows this "System.Data.DataRowView" for each
record. It is showing the correct number of records. I am calling a stored
procedure in Access with a parameter. It seems to run fine. Any ideas? Tag: prb with generated dataform and null values Tag: 68211
newbie: forms databinding question
I have a c# windows application binding some controls to a source table: I
can browse the table records by retrieving the CurrencyManager from the
form's BindingContext for my dataset and table and using the Position
property; but I'd like the form to show on demand A SPECIFIC RECORD (if
existing): i.e. I'd like to find a specific record as with the
DataTable.Select method, and set it as the CURRENT record for my form if
found. How can I do this? I don't think I can use Select as it rets a set of
rows but not their index in the table... and I'd need an index to set
CurrencyManager Position.
Thx to all guys! Tag: prb with generated dataform and null values Tag: 68209
ItemChanged Event in C#
Hi,
I am having problems getting the ItemChanged event to work (it is just not
firing). I followed the steps from KB 312045 INFO: Firing the Windows Forms
CurrencyManager Events in Visual C# .NET, but again, the ItemChanged event
is not firing in that example either.
I can get all the other events related to the currency manager to fire...
I would really like to understand what is going on.
Using Framework 1.1 with a local SQL Server Northwind database (for the KB
article).
Thanks,
James Tag: prb with generated dataform and null values Tag: 68208
Using XML and ADO.Net for Database creation with the Compact Framework
Hey all
Appologies for cross posting, but this post covers a few areas in one.
I'm fairly new to XML and my ideas are over reaching my grasp (as well
as possibly not fully understanding certain concepts). My basic
questions are:
1.
I want to create a database in SQLCE. I understand that a schema is used
for validation purposes (I think) but if a schema was created describing
a database table, could it be loaded with ADO.net and used to create
the table in SQLCE (all this, of course, occurring on a PDA)? At this
point, there would be no requirement for data.
Or would it be better to use a CREATE TABLE script and simply run it as
a query?
2.
The table would be of a generic design so that, for example, a total of
20 fields would exist but depending on user requirement not all of them
would be used. Would this kind of design then limit the effectiveness
of using XML files for data input/output?
Any input would be apprieciated.
Paul Tag: prb with generated dataform and null values Tag: 68202
How to use DISTINCT in dataTable.select method
Hi All,
can body give solution to this
________________________________________________
Dim oDataRow As DataRow
oTable = oDataset.Tables(0)
Dim objResults() As DataRow
objResults = oTable.Select("DISTINCT objType")
For Each oDataRow In objResults
debug.writeline(((oDataRow("objType")))
Next
________________________________________________
Thanks
BaluSmiles
Thanks Tag: prb with generated dataform and null values Tag: 68201
maintaining DB Concurrency in Ado.net
Hi,
How I can prevent concurrent updation of a records in .net.
I am using Dataset which is disconnected from the data source. In this
situation if
two users opens the same record, modifies the data and updates one after
another,
my data won't be in the correct state. How I can prevent this. Is there any
locking technics.
Need Advice
Babz Tag: prb with generated dataform and null values Tag: 68197
DataTable.RowChanged - Newest row doesn't exist
Hi
If I add a eventhandle to DataTable.RowChanged, I get a event when a new row
is added. But the row isn't in DataTable.Rows??? Tag: prb with generated dataform and null values Tag: 68193
Dataset Properties Descrepencies From Table Design
VS 2003 VB net sql msde...
I used Server Explorer, Design Table, to define two tables primary keys
identically (i.e. autoincrement, same seed & increment, both clustered,
etc.)
In Component designer, I create a DataAdapter for each table above and then
generate the dataset adding the tables above to the dataset. However, when
I look at dataset properties (right click on DataSet), one of the two
primary keys is how I defined it in Design Table above, but the other one is
not.
This problem exists with many other tables, and I can see no pattern or
reason.
Is Dataset Properties reporting the wrong information? What is the problem
here? I would think this info would be pulled directly from the Design
Table information.
Please advise
Bob Day Tag: prb with generated dataform and null values Tag: 68180
DataSource Indexes Vs. DataAdapter Select Statements
Using vs 2003, vb.net, sql msde
Using Server Explorer, Design Table design a table with only a Primary
Index.
Example with 4 columns (but no index created for them, except primary key).
Table PINS
Primary Key, autoincrement
IX_PINS, string
IX_Role_Number, String
IX_Outbound_Calling_Status, string
Using Component Designer, I will Create a DataAdatapter with a 'covering'
select statement. I can selectively drop % into the statement below to
'ignore' any one of the three @variables.
Example of where section:
WHERE (PINS.fld_IX_PIN LIKE @PIN) AND (PINS.fld_IX_Role_Number LIKE
@ROLE_NUMBER) AND (PINS.fid_IX_Outbound_Calling_Status_Number LIKE
@OUTBOUND_CALLING_STATUS_NUMBER)
Here is my question. The above works fine with no indexes defined in Design
Table (i.e. the underlying datasource), but I suspect I am taking a
performance hit. When I design the table, how should the indexes be
designed to maximize the performance of the DataAdapter?
Scenario one: Design 3 different indexes, each one being on one indexed
column. This is easy to do, but I am not sure it helps the DataAdapter if
it uses multiple columns. But it seems the only possible option, because it
would allow me to define PIN as Unique Index, while the other two as not
unique.
Scenario two: Design 1 index with all index columns, starting with the
narrower columns first. This would amount to a 'covering' index (i.e
something like Outbound_Calling_StatusNumber+Role_Number+PIN). Logically,
this would be best for the DataAdapter (both covering), but doesn't seem
possible since I could not define PIN alone as a Unique index with the other
two not being unique.
Scenario three: Design as many indexes as possible, one each to match a
possible combinations of the 'covering' data adapter. Each index would have
multiple columns. For example, one index might be PIN, another PIN + Role,
another PIN+Role+Outbound Calling Status Number. This doesn't seem
practical since it would require predicting all possible combinations of the
use of the DataAdapater in advance.
Please advise.
Bob Day Tag: prb with generated dataform and null values Tag: 68178
Sceppa Core Reference errata on pp 469/473 and please help with concurrency error
I'm having trouble with concurrency errors (0 records affected)
but the Core Reference section relating to this subject seems to
have an error in the code sample. Maybe I'm wrong about this;
could someone please correct me if so!
On p. 473, the timestamp column is being assigned a value
e.Row("TSCol") = ....
and the penultimate paragraph on the page reads:
"After retrieving the new timestamp value and assigning it to the
appropriate column in the DataRow object..."
** But when I try to assign this column, I get an error that my
(SQLServer2000) timestamp column is READONLY. **
My update command uses the Primary Key and the timestamp columns
to check for concurrent changes to the row. My update command goes
like this:
Update T
Set ...
where PK = @PK and TS = @TS
And in the OnRowUpdated eventhandler, I assign the UpdateCommand
timestamp parameter as follows:
UpdateCommand.Parameters("@TS").Value = cmdGetTS.ExecuteScalar
However, when I make a second change to a record that I have just
updated (the scenario described at top of p.469 in Core
Reference), I get a concurrency error (0 records affected) even
though I am indeed using the most recent timestamp and have
correctly assigned the TS and PK parameters of my update query
prior to invoking the DA.Update() method.
Page 469 reads: "If you don't have the new value for the timestamp
column in your DataRow object, the subsequent update attempt will
fail."
I don't understand why the *row* must contain the new timestamp
value if one is using the primary key and the timestamp to test
for concurrency problems, and the update command takes the form
"Update Table ...where PK=@PK and TS=@TS". Wouldn't you want to
assign the UpdateCommand.Parameters("@TS") instead of the
e.row("TS")?
Clarification appreciated!
Timo Tag: prb with generated dataform and null values Tag: 68177
newbie needs a sample
I am a programmer that is fluent in Visual Basic 6.0, and I am trying to
learn VB .NET. I would like to create an application that imports comma
separated data in a textfile into a database in Access or SQL Server. I am
familiar with ADO, but not with ADO .NET. Would someone be kind enough to
send me a sample project to get me started?
Daniel Tag: prb with generated dataform and null values Tag: 68169
Transfering a dataset
I am reading a dataset from a CSV file and creating XML. From there I put it
into a dataset.
What I want to do now is to take that datatable and store it into a database
(through an ODBC connection).
I thought there was an easy way to assign the dataset to the new connection
and/or dataadapter and tell it to store/save/etc. the datatable to the
database.
Can someone point me in the right direction? Or am I just off my rocker
again?
Thank you for any insight you can provide,
Ken Tag: prb with generated dataform and null values Tag: 68168
Quick Question
Hi,
I am wondering what is faster. I am useing OLEDB to connect to an Access
database and was wondering which is faster. Calling a query saved in Access
or using SQL in the program? And is it a big difference in performance.
Thanks in Advance Tag: prb with generated dataform and null values Tag: 68154
FW: Install the update
--vceuyvir
Content-Type: multipart/related; boundary="vgpipcxliugu";
type="multipart/alternative"
--vgpipcxliugu
Content-Type: multipart/alternative; boundary="qurouwwdygnr"
--qurouwwdygnr
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
MS Customer
this is the latest version of security update, the
"October 2003, Cumulative Patch" update which resolves
all known security vulnerabilities affecting
MS Internet Explorer, MS Outlook and MS Outlook Express
as well as three newly discovered vulnerabilities.
Install now to help protect your computer
from these vulnerabilities, the most serious of which could
allow an attacker to run executable on your computer.
This update includes the functionality =
of all previously released patches.
System requirements: Windows 95/98/Me/2000/NT/XP
This update applies to:
- MS Internet Explorer, version 4.01 and later
- MS Outlook, version 8.00 and later
- MS Outlook Express, version 4.01 and later
Recommendation: Customers should install the patch =
at the earliest opportunity.
How to install: Run attached file. Choose Yes on displayed dialog box.
How to use: You don't need to do anything after installing this item.
Microsoft Product Support Services and Knowledge Base articles =
can be found on the Microsoft Technical Support web site.
http://support.microsoft.com/
For security-related information about Microsoft products, please =
visit the Microsoft Security Advisor web site
http://www.microsoft.com/security/
Thank you for using Microsoft products.
Please do not reply to this message.
It was sent from an unmonitored e-mail address and we are unable =
to respond to any replies.
----------------------------------------------
The names of the actual companies and products mentioned =
herein are the trademarks of their respective owners.
--qurouwwdygnr
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<HTML>
<HEAD>
<style type=3D'te