Question about the DataSet Merge.
Dear All,
Now i have a two dataset. they have same db structure and same columns and
same rows.
just the content is not same between them.
for example:
datagrid 1:
name,sex,order_quality
shenzhen benny,male,1000
shanghai allen,male,2000
hangzhou kevin,male,3000
datagrid 2:
name,sex,order_quality
shenzhen dragon,male,1000
shanghai leo,male,2000
hangzhou james,male,3000
sturcture is sames as the datagrid1.
now i want to merge them into one datagrid. how to do it? (i can't used
ado's Merge command, because it's not full fill my requirement).
i want the combination of these two grids into:
name,sex,order_quality,name1,sex1,order_quality1
shenzhen benny,male,1000,dragon,male,1000
shanghai allen,male,2000,leo,male,2000
hangzhou kevin,male,3000,james,male,3000
how to do it for the combination of the above?
because the Merge command is only for the data merger for vertical. not
for the horizontal. Now i must to used two for...loop...to finish this
requirement.
But I thinking whether i can get an easily ways to finish that. How is yor
suggestion?
Thanks,
Benny Ng Tag: Check these dot net Interview Questions Tag: 134930
What is a good strategy for joining data from separate databases
I have a situation where I must restructure my data access, and was hoping
the community could give me pointers or links to articles that would help.
My situation is that I need to query data from two separate databases. One
is my application's own database, and the other is a Data Mart created for
me with a view I access. The way I do it currently requires that the
SQL-Servers be linked, and, given our security setup, on the same
SQL-Server.
Currently the cross database queries take two forms:
SELECT field FROM MyAppDataMart..vwAppData vw
JOIN MyOwnDatabaseTable tbl ON vw.Field = tbl.Field
OR
SELECT field FROM MyAppDataMart..vwAppData vw
WHERE NOT EXISTS(SELECT field FROM MyOwnDatabaseTable tbl WHERE vw.Field =
tbl.Field)
My current .NET business object merely makes a single stored procedure call
to retrieve a resultset, with any joins required handled by the stored
procedure. It is now considered unacceptable to have a dependency like that
in the stored procedure and I need to re-structure the data access such that
the .NET business object retrieves data separately from each database
eliminiating the need for one database to be able to be linked or even aware
of the other.
This means, however, that I must handle any JOIN or EXISTS logic in my
business object, and I am looking for strategies to accomplish that. From
what I have read so far, I'm not sure the DataRelation in ADO.NET can
enforce logic more complex than a INNER JOIN.
In short, what I need to go to is from
Existing:
-Call stored procedure which bridges Database1 and Database2 and returns a
resultset.
Desired:
-Retrieve info from Database1
-Retrieve info from Database2
-Apply any logic such as JOIN or EXISTS or NOT EXISTS to filter data
-Return resultset.
Any pointers or links would be greatly appreciated, thanks. Tag: Check these dot net Interview Questions Tag: 134912
reuse connection object with diff username password?
I have an ado.net based application (using BDP borland data provider actually). Everything is working fine. Up till now the connection string for my single connection object has been hard coded. set in designer. Now its time to implement login functionality using different user names and passwords. For a 'login' I figured, ok i'll close the connection if its open, then just change the ConnectionString. I set the exact same connection string as designer, I just set different username & password values.
The second time I run thru this cycle however I get strange exceptions when trying to close the connection. "No pool found to release connection". Then when I go to use it I get "connection already open".
The big question is, are connection objects meant to be reused in this manner, or must I new a new connection instance if I want to have a different connection string?
thanks
---
Posted via DotNetSlackers.com Tag: Check these dot net Interview Questions Tag: 134891
Schema.ini is ignored
Hi,
i have another problem yet with |-seperated values:
i have my connection:
connCSV = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\path;Extended Properties=""Text""")
and my schema.ini:
[test.txt]
Format=Delimited(|)
but i get one big field containing text like "name|phone|street|" and
so on.
yesterday it worked, today i juggled a little with the code and i don't
know what's wrong here!?
has anyone an idea, i'm going crazy on this!!!! :-(
thanks a lot :-)
chris Tag: Check these dot net Interview Questions Tag: 134890
SqlTransaction rollback error
Hi,
I've read through some posts on this error but none seem to exemplify
what I had happen to me and wanted to see if anyone else has seen this.
I know a lot of people like to see code, it's going to be hard to show
you code examples as I'm using a lot of our common code (which is
large) and some of that wraps Microsoft's application blocks. I'll try
to explain it as best I can though:
Basically, I have an app that is doing some writing to the database
(don't they all? :)) and is using our common data code for committing
and rolling back transactions. The data code has a class that I'm
using that keeps a connection object open.
In testing, my app took a very short period of time to run - but in
production it is taking a much longer time (another common problem I'm
sure). However, it took so long that I ended up getting this error:
"This SqlTransaction has completed; it is no longer usable."
My thought is that since I kept a connection object open and that the
application took waaaayyy longer to run through than it should (over 8
hours), that the connection was lost and that is why I got this error
because it couldn't use a transaction on a closed connection. Does
that sound like a reasonable explanation of why I might get an error
like this?
Note: By the way, I am fixing my performance problem - it's outside
the scope of this question though. :) Tag: Check these dot net Interview Questions Tag: 134886
Bad record count importing excel spreadsheet to DataAdapter?
Hello!
I'm using the code below to import an Excel datasheet into an ado.net
table. The problem is, when I
get to the point where I want to iterate the recods, it always thinks
that there is 999 records in the table! If the table (worksheet) is
larger than that, then it returns an equally fictious number (always
way more).
Does anybody have any idea what I'm doing wrong? I'ts an excel 2003
spreadsheet that I'm reading from. Thanks in advance!
Sub readSheet()
Dim excelConn As New System.Data.OleDb.OleDbConnection
excelConn.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\MySpreadSheet.xls;"
& _
"Extended Properties=""Excel
8.0;HDR=Yes;"""
excelConn.Open()
Dim da As New OleDbDataAdapter("Select * From [SheetName$]",
excelConn)
Dim escapeExit As Boolean = False
Dim ds As DataSet = New DataSet()
Dim dc As DataColumn = Nothing
Dim dt As DataTable = Nothing
Dim rec As String = ""
Dim i As Integer = 0
Dim x As Integer = 0
da.Fill(ds)
dt = excelConn.GetSchema
Dim dr As DataRow
While Not Me.bwWorker.CancellationPending
'HERE'S THE PROBLEM: IT ALWAYS DECIDES THAT THERE'S 999
RECORDS!!!
For Each dr In ds.Tables(0).Rows
rec = ""
For x = 0 To UBound(dr.ItemArray)
rec = rec & " " & dr.ItemArray(x).ToString
Next
logIt(txtOutput.Text & ControlChars.CrLf & rec)
'Next
Next
End While
excelConn.Close()
excelConn.Dispose()
End Sub Tag: Check these dot net Interview Questions Tag: 134882
SQL Server Express Error on Connection
My application uses the following code to attach and open a connection to an
SQL Server Express Database:
Dim conDatabase As New SqlConnection("Data
Source=.\SQLEXPRESS;AttachDbFilename="c:\database.mdf";Integrated
Security=True;Connect Timeout=30;User Instance=True")
conDatabase.Open()
The first time this works fine, then my application detatches the database
from SQL Server Express using SSEUTIL.
Then the user tries to attach and connect to another database (using the
same code as above) and I get this error:
A first chance exception of type 'System.Data.SqlClient.SqlException'
occurred in System.Data.dll
System.Data.SqlClient.SqlException: Unable to open the physical file
"c:\anotherpath\database.mdf". Operating system error 32: "32(error not
found)".
An attempt to attach an auto-named database for file
c:\anotherpath\database.mdf failed. A database with the same name exists, or
specified file cannot be opened, or it is located on UNC share.
Now the databases do have the same filename (in a different folder) but I
have checked that after the first database is detached, that SSEUTIL reports
that only the orginal system databases are attcahed by using "SSEUTIL -l".
So, no, a database with the same name is not attached.
The database is not located on a UNC share.
Then if I re-write my code to continue calling the Open method of the
connection until it is successful, it eventually works. This typically takes
around 5000 attempts.
Can anyone give me any ideas about what may be causing this problem?
TIA Tag: Check these dot net Interview Questions Tag: 134881
Querying a Dataset
I have a dataset populated from a variety of sources, such as Access
Database, SQL Database and Web services.
I would like to do a query including JOINs, LEFT, RIGHT, INNER, WHERE clause
etc in this dataset.
What's the best way to do it?
Evan Camilleri Tag: Check these dot net Interview Questions Tag: 134876
DataAdapter.Update bug updating Child table via Relations / RowState corrupted?
Hi all. .Net 2.0.
It seems the DataAdapter.Update Method changes the RowState of child records
to 'Modified' when updating them through a Relation.
If the child records' .RowState is "Added" or "Deleted," shouldn't they STAY
that way? Otherwise when you try to update the child table, you get
concurrency errors (record doesn't exist to update) or records fail to
delete.
Chris B. Tag: Check these dot net Interview Questions Tag: 134857
Data Provider for Oracle: MS version vs. Oracle?
Anyone have experience with the provider from Microsoft vs. the one from
Oracle? I haven't looked very much at either.
One would assume that the one written by Oracle itself should perform
better, since they should be able to optimize it?
Any sort of feedback or experience with either of these? Tag: Check these dot net Interview Questions Tag: 134850
updating child records in a DataSet w/ new autoinc values after parent insert?
Hi all. Using Dot Net 2.0.
I have a typed dataset generated by VS. It contains a parent and a child
table with a relationship set up in the MSSQL database and showing in the
dataset. _Both_ tables have new records that need to be added to database.
I'm able to retrieve the server's autoinc values on the parent table, but I
can't seem to get my data adaper to filter the new autoinc values down to
the foreign key field in the child table.
HOW EXACTLY is this done???
I'm currently doing 3 things:
1. Added an output parameter to the insert command to grab the new autoinc
value and feed it into my autoinc field.
2. Set insertCommand.UpdatedRowSource = UpdateRowSource.Both (figure good
idea to grab it all).
3. Appended " SELECT @" + identityColumn.ColumnName + " = SCOPE_IDENTITY()"
to the insert command.
Does #3 keep the entire column's values from being fed back to the DataTable
row?
Do I need to AcceptChanges?
What about if the operation fails and the transaction is rolled back, how do
I undo changes made to the dataset?
THANKS!!!
Chris B. Tag: Check these dot net Interview Questions Tag: 134845
Schema.ini for all textfiles in the folder
Hi,
i try to import several cvs-files into a database.
These csv's are delimited by a "|". (don't ask me why it's named csv
then ;-)
.Net seems to ignore my settings in the connectionstring:
...Properties=""text;HDR=Yes;FMT=Custom-Delimited(|)"""
i get a table with one field like name|street|phone and so on
So i created a schema.ini and it works with one file, but:
in my folder are up to 500 csv-files and im not willing to write all
that stuff.
now here is my question:
is there a way for a global setting for that folder? in schema.ini i
tried
[*.csv]
format=delimited(|)
but it didn't work.
i could read out all names (changing daily) of that folder an create a
schema.ini, but in that case time plays a role and i would be glad if i
coud save this time.
thanks
chris Tag: Check these dot net Interview Questions Tag: 134832
[Datagrid Onclick Error]
Hi all,
Anyone know how to solve the datagrid onclick problem as below:
i click a row in a datagrid then the row change to another color, but
when i click on another row, the previous row that i clicked still red
color, so now have two row that red in color.
what I want is the previous row that i clicked change back to its
original color without post back the page.
I am using code below:
<script language="JavaScript">
var lastColorUsed;
function prettyDG_changeBackColor(row, highlight)
{
if (highlight)
{
lastColorUsed = row.style.backgroundColor;
row.style.backgroundColor = 'pink';
}
else
if (row.style.backgroundColor == 'pink')
{
row.style.backgroundColor = lastColorUsed;
}
}
var lastRowSelected;
var lastRowSelectedColorUsed;
function prettyDG_changeBackColor2(row)
{
var color = lastRowSelectedColorUsed;
lastRowSelectedColorUsed= row.style.backgroundColor;
row.style.backgroundColor = 'aqua';
lastRowSelected = row;
if (lastRowSelected != null)
{
lastRowSelected.backgroundColor = color;
lastRowSelected = row;
}
}
</script>
while the code behind as below:
e.Item.Attributes.Add("onmouseover",
"prettyDG_changeBackColor(this, true);")
e.Item.Attributes.Add("onmouseout",
"prettyDG_changeBackColor(this, false);")
e.Item.Attributes.Add("onclick",
"prettyDG_changeBackColor2(this, true);")
The logic is when mouse over, the row become 'pink' color,
when mouse out, if the row color is 'Pink' then change to transparent
else don't change color
when clicked, the row become 'Aqua' color.
Please advice on how to change back the 'Aqua' to transparent color if
we clicked on another row, this mean there will not more than 1 row
with 'Aqua' color. Tag: Check these dot net Interview Questions Tag: 134825
DataView.Find not working with GUID
Using .NET 2.0, I have a DataView with two columns: JobID (a GUID) and
JobNumber (an integer). DataView.Sort = "JobID".
When I perform a DataView.Find(SomeJobID), I always get a result indicating
the row was found, but it's the wrong row (code below). In the code below,
as long as JobID is a valid GUID, the Offset is always the wrong row.
This code seems to fail only when the DataView.Sort is a GUID - works fine
on other types of data.
Any ideas? Is this a bug in .NET 2.0? I've seen this same problem described
elsewhere on the Internet, but no responses or answers.
Thanks in advance,
Warren
Offset = DV.Find(JobID);
if (Offset > -1)
{
JobNumberText = DV[Offset]["JobNumber"].ToString();
} //JobID was located Tag: Check these dot net Interview Questions Tag: 134824
RowFilter date expression
Is there an easy way to filter a datetime column on the year. The following
does not work:
YEAR(BeginDT) = 2006
Also does any one know if there is a list of valid expressions for the
rowFilter?
Thanks for your help. Tag: Check these dot net Interview Questions Tag: 134818
OleDbPermission failed
I am trying to test distributing a Windows application that accesses a
Jet DB (.mdb) database file. On my development box running Windows XP
Pro with Office Pro (and Access) installed, it runs fine. On my test
machine running Windows Server 2003 without Office, it fails with
Request for the permission of type 'System.Data.OleDb.OleDbPermission,
System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.
I have checked, and the Jet Database engine is installed on that
machine. It also has Framework 1.1 and 2.0 installed (this app was
developed using 2.0). The code is straight from Microsoft's sample
ado.net application
http://msdn2.microsoft.com/en-us/library/dw70f090.aspx using the OleDb
connector.
I have found many clues on how to fix this problem when using ASP.NET,
but nothing when it occurs in a Windows application. Anyone have any
ideas?
Thanks,
Carole Tag: Check these dot net Interview Questions Tag: 134817
InsertCommand gives "Must declare the scalar variable "@..."
Hi,
I have a strange problem and i think the sollutions is simple, but I
don't get it.
I have the following piece of code
Dim pCommand As New System.Data.OleDb.OleDbCommand
Dim sSql As String = ""
sSql = "INSERT INTO dbo.Uitgaven ( "
sSql &= " UitgavenOmschrijving,"
sSql &= " UitgavenBedrag,"
sSql &= " UitgavenKostenPostID,"
sSql &= " UitgavenDatum"
sSql &= " ) "
sSql &= "VALUES ( "
sSql &= " @UitgavenOmschrijving,"
sSql &= " @UitgavenBedrag,"
sSql &= " @UitgavenKostenPostID,"
sSql &= " @UitgavenDatum"
sSql &= " ) "
pCommand.CommandText = sSql
pCommand.UpdatedRowSource = UpdateRowSource.Both
With pCommand
.Parameters.Add("@UitgavenOmschrijving", OleDbType.VarChar,
50, "UitgavenOmschrijving")
.Parameters.Add("@UitgavenBedrag", OleDbType.Double, 4,
"UitgavenBedrag")
.Parameters.Add("@uitgavenKostenPostID", OleDbType.Integer,
4, "UitgavenKostenPostID")
.Parameters.Add("@UitgavenDatum", OleDbType.Date, 0,
"UitgavenDatum")
End With
pCommand.Connection = pDB.Connection
For iTeller As Integer = 0 To pDS.Tables(0).Rows.Count - 1
Try
With pCommand
.Parameters("@UitgavenOmschrijving").Value =
pDS.Tables(0).Rows(iTeller).Item(3)
.Parameters("@UitgavenBedrag").Value =
pDS.Tables(0).Rows(iTeller).Item(1)
.Parameters("@uitgavenKostenPostID").Value =
pDS.Tables(0).Rows(iTeller).Item(2)
.Parameters("@UitgavenDatum").Value =
pDS.Tables(0).Rows(iTeller).Item(0)
End With
pCommand.CommandType = CommandType.Text
MessageBox.Show(pCommand.ExecuteNonQuery)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Next
I get a error "Mus declare the scalar variable "@UitgavenOmschrijving".
I have not include the primary key because that is a database thing for
me.
Can anyone give me the sollution for my problem
Thanks already
Klaasjan Tag: Check these dot net Interview Questions Tag: 134816
Save DataSet to Data Definition File
I have hundreds of Crystal Reports which have been created on Data
Definition Files (ADO Recordset saved into ttx file)
All these reports are invoked from VB6 application, and as a datasource for
each of them I supply ADO Recordset.
Everything works fine.
Now I'm working on rewriting VB6 app in VB 2005. Using the same SQL Server
SPs, I populate DataTables with data and use those DataTables as datasources
for Crystal Reports.
Everything works.
In case I change something in underlying SP of any report, I can easy
recreate TTX file in VB6.
I'd like to have this ability in VB 2005.
Is there any method of DataSet or DataTable object which saves the structure
of underlying DataTable into TTX file.
I couldn't find anything.
I can recreate any TTX file manually, but I would want to do it using some
methods of ADO.NET.
Replacing TTX files with XML is not good too, because as I said I have
hundreds of reports, and I will need to recreate each of them in case I
change their bases (TTX with XML)
Any idea please Tag: Check these dot net Interview Questions Tag: 134813
Connection String - how to include timeout?
Hi,
I am having a problem creating a connection string in DotNet. Here is
an example below:
"Integrated
Security=SSPI;database=MyDatabase;server=MySqlServer;Connect
Timeout=60"
The problem is in the timeout setting. I am running a query using this
connection string and it is timing out at 30 seconds, it does not go to
the 60 seconds. I figured it must be because it's a connection timeout
setting I've used above and not an actual query timeout setting.
However, I cannot determine how to set a query timeout setting in my
connection string. Is there a way to do this? Tag: Check these dot net Interview Questions Tag: 134811
Best way to reference a value in DataRowView
When looping over items in the RowDataBound event for a GridView
(ASP.NET) I can access e.Row.DataItem which shows as a DataRowView.
The following code allows me to access the data for that row.
e.Row.DataItem, System.Data.DataRowView).Row.Item(0)
Is there a better way to access that data? This syntax looks very ugly
and potentially error prone.
Ideally I would simply use code like this...
e.Row.DataItem("id")
But I cannot seem to do that.
Brennan Stehling
http://brennan.offwhite.net/blog/ Tag: Check these dot net Interview Questions Tag: 134809
Trouble displaying info from access db
Hi Everyone,
I have the project below where I'm pulling out information from 1 table
"Subjects", pulling the Subjects, and SubjectCode. The Subjects are
displaying in the Combo Box just fine, but I can not get the
corresponding Subject Code to display in the Label.
I have 2 Data adapters/dataset,1 for Subjects, and the other for
SubjectCode, along with a Data View setup.
I'm a newbie on VB.NET. This project is pulling from an Access DB. Is
there anything that I should be looking for, or doing wrong that I'm
not getting the Subject Code to display in the Label?
Any help would be appreciated.
__________________________________
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Fill the List box
dbSubject.Fill(DsSubject1)
dbSubjectCode.Fill(DsSubjectCode2)
DisplayRecordPosition()
End Sub
Private Sub cboSubjectName_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboSubjectName.SelectedIndexChanged
' DsSubject1.Clear()
' dbSubject.SelectCommand.Parameters("Subjects").Value =
cboSubjectName.Text
' dbSubjectCode.Fill(DsSubjectCode2)
End Sub
Private Sub lblSubName_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles lblSubName.Click
DsSubjectCode2.Clear()
dbSubjectCode.SelectCommand.Parameters("SubjectCode").Value =
lblSubName.Text
dbSubjectCode.Fill(DsSubjectCode2)
End Sub
'*****General Procedures*****
Private Sub DisplayRecordPosition()
Dim intRecordCount As Integer
Dim intRecordPosition As Integer
intRecordCount = DsSubject1.Tables("Subjects").Rows.Count
If intRecordCount = 0 Then
lblSubName.Text = "(No records)"
Else
intRecordPosition = Me.BindingContext(DsSubject1,
"Subjects").Position + 1
lblSubName.Text = "Record: " & intRecordPosition.ToString _
& " of " & intRecordCount.ToString
End If
End Sub
End Class
_____________________________________________________ Tag: Check these dot net Interview Questions Tag: 134808
Oracle
Hi,
My app needs support for Oracle 10 g database : reading (select ...) +
updating + calling stored procedures + distributed transactions eventually.
I built it in VS 2005 (ado.net 2.0).
What should I use ? Microsoft Oracle .NET Managed provider or Oracle Data
Provider for .NET 2.0 ?
I want to know the limitations of each one, tricky pbs, licensing. Microsoft
did release a new Oracle.NET for .NET 2.0 ?? I found only the version 1.0
(http://www.microsoft.com/downloads/details.aspx?FamilyID=4f55d429-17dc-45ea-bfb3-076d1c052524&DisplayLang=en).
Does anyone know if I can use promotable transactions (TransactionScope)
when working with Oracle 10g ?
Thanks for any advice Tag: Check these dot net Interview Questions Tag: 134805
Re (by Cor): update DataSet - transaction
I think you finally got me!
This is an answer i was looking for.
But it just feels like a walkaround instead a straight forward, 'by the book
(MSDN)' stuff.
It's hard to belive that Microsoft did not provide something simpler for a
common functionality.
Why introducing TableAdapters when transaction is not provided for them?
Also i can hardy belive that TableAdapters do not have a base class (or
interface) so it's making it hard to program generic solution for them.
Oh, yeah, can you please provide code, that would be really heplful.
Thanx!
> However, I thuougth that I solved with casting the tableadapter again to a
> dataadapter and than add the transaction to that.
>
>
> Cor
>> "TheMaxx" <themaxxREMOVE@net.hr> schreef in bericht
>> news:ejciit$55$1@magcargo.vodatel.hr...
>>>I have two tables in dataset, and appropriate TableAdapters.
>>>
>>> How can i update both tables, but in transaction?
>>>
>>> I other words:
>>>
>>> THIS:
>>> MyDSTableAdapters.Table1TableAdapter a1 = new ...
>>> MyDSTableAdapters.Table1TableAdapter a2 = new ...
>>>
>>> a1.Update(dt1);
>>> a2.Update(dt2);
>>>
>>> but where to put transaction ?
>>>
>>> P.S. DataSet and TableAdapters are generated via VS 2005 form SQL 2000
>>> ServerExplorer drag n' drop
>>> Tag: Check these dot net Interview Questions Tag: 134804
Datagridview image column nulls
I've got a datagridview bound to Sql2k database. When the image columns
return null, I get the goofy looking [X] in the column instead of a blank.
Anyone know how to make that just appear as empty instead of the default
[X]? I would also like that to appear as empty when I insert a new row
instead of the [X] if that is possible. Tag: Check these dot net Interview Questions Tag: 134789
Insert in Access threw typed dataset Tableadapter
After creating the typed dataset , i've created the wanted sql functions in
the .xsd file. Now i'm trying to enter the data into database threw the
insert query that was automaticly created by .net .
Must add that in the access itself the sql query work , so i'm pretty sure
that the syntax is correct.
Also the fill of the datatables does work , so the connection to the
database is also right.
Insert into 'tablename' ('col1','col2') values (?,?) - was created by .net
at the beggining. after testing the query at access it worked when i've
changed it to:
Insert into 'tablename' ('col1','col2') values (col1,col2) - and actually
entered the data into database.
The data wouldn't enter.
Are there any more adjustment i have to do? Tag: Check these dot net Interview Questions Tag: 134784
Beginning question for Access OLEDBUpdate command
I used the wizard in VB.NET 2003 to generate a data adapter and it created
the following update command. It seems like the WHERE clause would never
evaluate to true? Am I reading this wrong?
The member_ID is the key for the table but it looks like the 2 statements
checking the address_1 and address_2 values would only be true if no changes
were made.
Me.OleDbUpdateCommand1.CommandText = "UPDATE Member_Listing SET address_1 =
?, address_2 = ? WHERE (member_ID = ?) AND (address_1 = ? OR ? IS NULL AND
address_1 IS NULL) AND (address_2 = ? OR ? IS NULL AND address_2 IS NULL)
Thanks for your help.
Dave Tag: Check these dot net Interview Questions Tag: 134769
Migrating from MS ACCESS 97 to SSEv
I am writing an application to migrate an Access 97 database file to SQL
Server Everywhere database file in VB.NET
I have code that builds the required tables in a new SSEv database file,
"CREATE TABLE", but am stumped at not being able to detect if the Access
field is AUTOINCREMENT.
I use standard methods to connect to the Access database, ADODB
The code field.Properties("ISAUTOINCREMENT").Value always returns false
even when the property value is AutoNumber in Access.
Also field.Properties("KEYCOLUMN").Value always returns False even when a
field is the primary key.
Does anyone have any solutions.
ADOX did not help either giving similar results
Garry Tag: Check these dot net Interview Questions Tag: 134764
please help! Error in update Access database
I have been trying to update in Access Database. I get this error "Syntax
error in UPDATE statement." What could be the problem or can somebody
suggest different solution.
I call this function from my main page.
Public Shared Function UpdateScholarship(ByVal ID As String, ByVal Name As
String, ByVal Amount As String, ByVal Year As String, ByVal Criteria As
String, ByVal Conditions As String)
Dim connection As New OleDbConnection(ConnectionToDatabase)
Dim UpdateString As String = "Update ScholarshipDescription Set
[Name]='" & Name & "', Amount='" & Amount & "', Year='" & Year & "',
Criteria='" & Criteria & "', conditions='" & Conditions & "' Where ID='" &
ID & "'"
Dim command As New OleDbCommand(UpdateString, connection)
connection.Open()
command.ExecuteNonQuery()
connection.Close() Tag: Check these dot net Interview Questions Tag: 134758
MS Access DAO -> ADO.NET Migration
I have an VB6 program that I wrote that access Microsoft Access
databases using DAO. DAO has methods and properties that are Access
specific (such as viewing and editing relationships or indexes on the
tables) I want to write a new version of the program in VB 2005, and I
want to use ADO.NET to access the data. Are there ways of changing the
indexes or relationships of the MS Access database using ADO.NET? Or do
I still need to use DAO to perform these operations?
As a side note, with a few tests that I've done already with some
queries, it seems like DAO is much faster than ADO.NET at running
queries and returning results. I am using the DataReader...does anyone
have any information about the differences etc? Thanks in advance... Tag: Check these dot net Interview Questions Tag: 134757
webservice - dsn - sql server
I've created ODBC DSN for sql server.
When i connect from win application works OK.
When i make WebService (on same machine) that connects to that ODBC
connection fails:
Error:
Server was unable to process request. --> ERROR [28000] [Microsoft][ODBC SQL
Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not
associated with a trusted SQL Server connection.
ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed
for user '(null)'. Reason: Not associated with a trusted SQL Server
connection.
ODBC is configured to use SQL Server authentication (login id and passwd) Tag: Check these dot net Interview Questions Tag: 134744
Can anyone explain this: Numeric or Value Error Line 1
I have a stored procedure that starts out like so:
PROCEDURE test_proc(param1 IN VARCHAR2, param2 IN VARCHAR2, param3 OUT
SYS_REFCURSOR) IS
v_var varchar2(5);
BEGIN
SELECT * FROM. . .
The procedure tested fine in PL/SQL Developer. When calling from
ODP.NET like so. . .
OracleCommand cmd = new OracleCommand("test_proc", <connection>);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("param1", "somevalue");
cmd.Parameters.Add("param2", "XX");
cmd.Parameters.Add("param3", OracleDbType.RefCursor,
ParameterDirection.Output);
DataSet ds = new DataSet();
OracleDataAdapter da = new OracleDataAdapter(cmd);
con.Open();
da.fill(ds);
con.Close();
. . .the procedure executed as expected. If I changed the value of
param2 to "XXX" or any value three chars long I got the "ORA-06502:
Numeric or Value Error at Line 1" error.
After beating my head against the wall for hours, I tried changing the
size of v_var to 50, and the error disappeared. Mind you, the error
was being thrown long before v_var was being set further down in the
proc. Even more interesting is that the possible values of v_var were
all *less than 5 chars wide.*
Can anyone explain this? Tag: Check these dot net Interview Questions Tag: 134730
Problem following first example in "Programming MS ADO.NET 2.0" by David Sceppa
I did the example twice with two different databases (Adventure works
using MS SQL Server 2005, and an MS Access database).
Although the data sources I used were different than Mr. Sceppa's, the
SQL Server DB (AdventureWorks) wored flawlessly while the trial using
the MS Access database did not. The apparent problem when I tried
using an MS Access database is that the database appears to be empty,
with only a schema (and in fact I know there is at least 80 MB of data
in it).
There are no compile time errors.
At compile time, and design time, I can see almost all of the database
objects in the MS Access database. The only things that seem to be
missing are the relationships among the tables. The tables and views
are all there!
At run time, there are no errors when using the Adventureworks data,
and I can browse through the data one person at a time. When I try to
run the project that uses the MS Access database, I get the following
errors:
A first chance exception of type 'System.InvalidOperationException'
occurred in System.Data.dll
A first chance exception of type 'System.InvalidOperationException'
occurred in System.Data.dll
The thread 0x570 has exited with code 0 (0x0).
The thread 0xe4c has exited with code 0 (0x0).
There is output prior to these messages, but that output contains no
reference to any problem implying the first mention of an exception
shown above is the first occurance of an error.
I do not have MS Access installed, but as I am running Windows XP Pro
(the 64 bit version), jet seems to be present. I am working within the
professional edition of MS Visual Studio 2005, and I have installed MS
SQL Server 2005.
WHY would I have problems getting a C# windows application using
ADO.NET 2 to use an MS Access database while using the same method to
develop the program to use an SQL Server database works just fine?
I find this very odd since I have another application (2 years old),
written in C++ and using ADO/MDAC to work with the very same MS Access
database, and this other application works fine (and this on the same
machine I'm trying to use to develop these programs)!
If it is the case that Jet is basically severely broken, is there an
easy way to move an Access database into SQL Server?
Ted Tag: Check these dot net Interview Questions Tag: 134727
DataAdapter for Insert
Hi, I'm using a DataAdapter with sqlserver(Express) in a server app.
The SQL Insert is generated with an additional Select when not checked off. How can the result of this generated select be accessed? GetData() with get all the data in the table and not the just inserted data.
Thanks
BoM Tag: Check these dot net Interview Questions Tag: 134726
2.0: well-written sample application?
Hello,
I am learning .NET 2.0 (C#, VB, ADO.NET, ASP.NET) and I am looking for a
well designed and coded database application - prefably using SQL Server
2005 and ASP.NET.
Could you give me a link to such appliacation or send me source?
Thank you VERY MUCH!
/RAM/ Tag: Check these dot net Interview Questions Tag: 134724
TransactionScope exception handling
Is there any way to have an DataReader.Read part of a TransactionScope but not cancel the transaction if the read fails?
I'm using a DataReader to get the result of a stored procedure which increments a counter. I'd like to add the read to
the transaction only if the read is successful. If the read isn't successful I don't want it to cancel the entire
distributed transaction but I will need to roll it back (since the SP updates a table) if some other part of the transaction fails. Tag: Check these dot net Interview Questions Tag: 134722
DataSet has no rows when proc is returning rows??
Hello,
Im going insane with this problem. I have a stored proc that returns 2
recordsets to a dataset. In the dataset i reference the recordsets by
their tables like below.
ds.tables[0]
ds.tables[1]
In the first table it says their are 0 rows. The columns get populated
but no rows. I run the proc outside VS and the results are correct. In
the datase i can reference the second table and pull the rows i need.
For what ever reason the first dataset is always empty. I have used
this methods before and works great but for some reason it doesnt like
the first recordset.
In my proc I have 'set nocount on'
code below.
Here is a run down of the proc.....
Query 1:
SELECT a.first_name ,a.last_name, upa.organization_id, b.index_code as
EmployeeID
FROM person_name a, person_indices b, v_user_profile_app upa
WHERE a.person_nbr = b.person_nbr
AND b.index_code = (SELECT c.code_nbr
FROM v_code_entries c
WHERE c.table_code = "INDXTP"
AND c.code = "EMPNUM")
Query 2:
Select RoleName FROM UserRoles WHERE person_nber=@person_nbr Tag: Check these dot net Interview Questions Tag: 134719
DaatSet has no rows when proc is returning rows??
Hello,
Im going insane with this problem. I have a stored proc that returns 2
recordsets to a dataset. In the dataset i reference the recordsets by
their tables like below.
ds.tables[0]
ds.tables[1]
In the first table it says their are 0 rows. The columns get populated
but no rows. I run the proc outside VS and the results are correct. In
the datase i can reference the second table and pull the rows i need.
For what ever reason the first dataset is always empty. I have used
this methods before and works great but for some reason it doesnt like
the first recordset.
In my proc I have 'set nocount on'
code below.
Here is a run down of the proc.....
Query 1:
SELECT a.first_name ,a.last_name, upa.organization_id, b.index_code as
EmployeeID
FROM person_name a, person_indices b, v_user_profile_app upa
WHERE a.person_nbr = b.person_nbr
AND b.index_code = (SELECT c.code_nbr
FROM v_code_entries c
WHERE c.table_code = "INDXTP"
AND c.code = "EMPNUM")
Query 2:
Select RoleName FROM UserRoles WHERE person_nber=@person_nbr Tag: Check these dot net Interview Questions Tag: 134718
Optimize DataTable Select Method
Hi all,
How can I optimize the DataTable Select Method to make it faster
Can I create a Text Index Search ?
Thanks alot
Regards Tag: Check these dot net Interview Questions Tag: 134715
Opening PDF document in new window on click of linkbutton column in datagrid
Hi,
I need to open PDF document in new window when i click on linkbutton
in datagrid.For that i have written code as below:
But the problem with this code is that it opens the new window ,but not
loading the pdf.Please let me know how can i solve this issue.
private void grdTest_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="View")
{
LinkButton btn =
e.Item.FindControl("linkView") as LinkButton;
GetPDF();
btn.Attributes.Add("Onclick","window.open('TestData.aspx');" +
"return false;");
}
}
Here is the GetPDF function:
public void GetPDF()
{
FileStream fs;
string fname;
fname = MapPath("../") + "via
project/documents/Mass_title.pdf";
fs = File.Open(fname, FileMode.Open);
byte[] data = new byte[fs.Length];
int i=(int)fs.Length;
fs.Read(data, 0, i);
fs.Close();
Response.Clear();
Response.Charset = "";
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition",
"inline;filename=pdfTest.pdf");
Response.BinaryWrite(data);
Response.End();
}
Thanks,
Vishnu Tag: Check these dot net Interview Questions Tag: 134714
BindingSource1.AddNew()
Help,
I have created Windows app with VS2005.
I then drop the datanavigator control and bindingsource control to the form.
I bind a dataset tablet to the binding source and set the navigator to the
bindingsource control , all wonderfull.
The Problem
I click to add a new record , it doesnt go to the end ? it goes to record 1
and seems to lose records 1 data.
I have tried adding my own button on there with the code
BindingSource1.AddNew()
, but this does the same. How do I got to the newly created record.
Thanks
Neil Tag: Check these dot net Interview Questions Tag: 134712
MS Data Application Block
Hi,
In .NET 1.0 and 1.1 I used the Microsoft Data Application Blocks for
executing Stored Procedures etc.
In .NET 2.0 is there a newer version of these blocks or has the way Data
Access works been changed?
Thanks,
C Tag: Check these dot net Interview Questions Tag: 134710
Why 1990 for ShortDate
I use a update command to update a smallDateTime filed:
Update [Checks] set Checks.CheckDate=''
It udpate the CheckDate field to 1990/01/01
Why? Tag: Check these dot net Interview Questions Tag: 134707
Concurrency violation
I'm just starting to try and learn ADO.NET and was following along in
Murach's VB.NET/ADO.NET book samples for typed databases with unbound
controls.
When I try to execute an update with the my data adapter and the data table
as a parameter, daMembers.Update(dsMembers.Member_Listing), I get a
concurrency violation. I'm not sure how to track down the problem.
Basically I'm doing the following; open the connection, set data adapters
selectcommand text, fill the dataset, get a data row from the table, put the
data into controls on a form, change the data, put the changes into the data
row, and execute the update command.
' load dataset
cnRosterDB.Open()
daMemberList.SelectCommand.CommandText = sSelectCommand
daMemberList.Fill(dsMembers)
cnRosterDB.Close()
' get a record
drMemberRow = dsMembers.Member_Listing(0)
With drMemberRow
txtID.Text = .member_ID
If .Islast_nameNull Then
txtLName.Text = ""
Else
txtLName.Text = .last_name
End If
If .Isfirst_nameNull Then
txtFName.Text = ""
Else
txtFName.Text = .first_name
End If
end with
' put edited data into data row
With drMemberRow
.member_ID = CInt(txtID.Text)
.last_name = txtLName.Text
.first_name = txtFName.Text
end with
' try to update the database
daMemberList.Update(DsMembers.Member_Listing)
Any guidance would be appreciated,
Thanks
Dave Tag: Check these dot net Interview Questions Tag: 134697
update values to excel data source using ADO.NET
I've been able to connect to my excel spreadsheet using ADO.NET and
display the data in a Datagrid. Now I need to know how to take the
values in the datagrid and repopulate the excel spreadsheet. The end
users will be editing the data in the datagrid and I have another
application that will be consuming the excel file. Again any help on
how to repopulate the entire datagrid to the existing excel spreadsheet
will be greatly appreciated.
Thanks
Christian Tag: Check these dot net Interview Questions Tag: 134696
convert DataColumn.GetType() into a DbType or SqlDbType?
I have a DataColumn, want to derive the DbType. I can do column.GetType()
but that's a system type, not a db type. How do I convert it to the
corresponding type?
Thanks much!
Chris B. Tag: Check these dot net Interview Questions Tag: 134695