|
Hey...In my coding...
I need a randomalphanumeric generator code...for a field in form1.aspx..This will be inserted as a primary key information in my database table...
If i implement randomalphanumeric generator it should be unique value..Plz help as soon as possible
the generated random alphanumeric string should be something like
TX12YZ57 format...
|
|
|
|
|
You can use GUID.NewGuid() if you are using c#/Vb.net
or
If you use sql server,GUID data type can be used
|
|
|
|
|
|
Hi,
Does anyone know how to return muliple tables from a stored procedure to an .Net Application.
For example if my sp has 3 separate select statements I want to return a dataset containing 3 tables with the results of the 3 select statements.
Any help would be greatly appreciated.
Cheers,
Craig
** I'd rather try and fail than fail to try **
|
|
|
|
|
Hi
Create a SP that contains 3 SP (all there should return out put)
generate typed dataset and drag and leave the SP on the data set
you can see the three tables created on the typed dataset.
Or else if you are not using typed dataset. and you are filling to simple data set, after filling data set
use like
someDataSet.Tables(0)
someDataSet.Tables(1)
someDataSet.Tables(2)
to access the tables data
Chinna Srihari
Tech Lead, Capgemini
|
|
|
|
|
DataSets are perfectly capable of handling multiple tables. There is no difference in acquiring multiple tables from a stored proc as there is in acquiring one table. In your case:
DataSet ds = new DataSet();
Console.WriteLine("Table 1 Rows: " + ds.Tables[0].Rows.Count().ToString();
Console.WriteLine("Table 2 Rows: " + ds.Tables[1].Rows.Count().ToString();
Console.WriteLine("Table 3 Rows: " + ds.Tab;es[2].Rows.Count().ToString();
|
|
|
|
|
The following would return three RESULTSETS from sql server:
SELECT * FROM CUSTOMER
SELECT * FROM INVOICE
SELECT * FROM INVOICE_DETAIL
through a SqlCommand object and a SqlDataAdapter you can fill a dataset with the resultset. If you're using a strongly-typed dataset, make sure to set the table mappings.
I could have been a little more detailed, but it's all in the MSDN help.
|
|
|
|
|
Hi Guys,
Im trying to modify a program that will run and can switch into two back-ends(MSSQL and MSACCESS) and initially it is working and with no issues using the MS SQL server side. But when I'm switching the connection into MSACCESS with same tables as with the MSSQL, some of the SQL command is not working. My question is, "Is it possible to switch into a differrent back-end such as SQL to access without changing any SQL commands ? "
|
|
|
|
|
armax75 wrote: My question is, "Is it possible to switch into a differrent back-end such as SQL to access without changing any SQL commands ? "
Generally, no!
As a possible suggestion:
You should create an abstract class that will handle data access. The interface (i.e. the public methods/properties) of the class should be database neutral. You can then create two inherited classes, one for Access specific things and one for SQL Server specific things. You then have some code (a factory method) that decides which of the derived classes to instantiate. The rest of your application only ever refers to the abstract base class.
public abstract class DataAccessObject
{
public abstract DataSet RunSomeQuery(string param1, int param2);
}
public class DataAccessObjectSqlServer : DataAccessObject
{
public override DataSet RunSomeQuery(string param1, int param2)
{
}
}
public class DataAccessObjectMSAccess : DataAccessObject
{
public override DataSet RunSomeQuery(string param1, int param2)
{
}
}
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Thank you Colin,
but my application uses a dataset, built by dataset wizard (Add datasource)from an Access db, what I want to do is to find a way to switch to SQL server at runtime using the same dataset. Changing the connection string the dataset's query don't function. I've used standard sql. There's a way to use an xml file that can change the query in dataset (according to the rigth database)set designer at compile time.
Best regards
Armando
|
|
|
|
|
armax75 wrote: built by dataset wizard
Well, there's your problem right there! Don't rely on wizards, learn how it actually works so you can leverage the technology to do what you want rather than a narrow set of possibilities provided by a dumbed down wizard.
armax75 wrote: what I want to do is to find a way to switch to SQL server at runtime using the same dataset
You can do that with the solution I proposed - if you do away with a reliance on wizard generated code.
armax75 wrote: Changing the connection string the dataset's query don't function
Of course not. There are many forms of the SQL langauge, each database implements its own varient.
armax75 wrote: I've used standard sql
Really? I wasn't aware that Access or SQL server used "Standard SQL". You might like to take a look at an open source project called NHibernate that uses its own SQL variant and translates that into the specific dialect used by the database system to which it is connecting.
armax75 wrote: There's a way to use an xml file that can change the query in dataset (according to the rigth database)set designer at compile time.
Datasets are database agnostic. They don't know anything about the database - that is the job of the Data Adapter.
You can use an XML file to contain the various dialects of SQL you might like to use, but the solution would be more useful at run time. If you are looking for a compile time switch why not look into #define[^], #if[^] and #endif[^]. But I'm confused, you said earlier you wanted to switch at run time. Which is it?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Take a look at MicroSoft's Data applicatiom block, Generally called Enterprise Library.
http://msdn.microsoft.com/practices/[^]
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Have several tables on SQL Server from a Web Hoster.
I have no way of actually coping the tables.
So using INSERT SELECT I thought I could just copy the entire table to tableName2 for back up.
I tried
INSERT Category2
SELECT * FROM Category
But it wants the table already defined. I know theres a way to create the table in the statement also.
Can anyone help.
Thanks,
Nick
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
SELECT * INTO Category2 FROM Category
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
|
Hi
I have SQL server 2000 on server machine. SQL client tools are not installed there. I want to detach a database on server. How can I do it?
Any suggestions?
Thanks
|
|
|
|
|
You can use Enterprise Manager from any machine that can see the server the database is on. You can then remotely detach the database.
To get Enterprise Manager to access a remote server, right-click SQL Server group and select New SQL Server Registration...
Follow the wizard (You can add the server name manually if it doesn't show up in the list on the Select a SQL Server page)
Now you have the server registered with Enterprise Manager you can operate on it - Just remember that any file paths for things are from the point of view of the remote server, not local paths.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
|
You can use the sp_detach_db stored procedure.
Note:
Only members of the sysadmin fixed server role can execute sp_detach_db.
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
Hi guys,
I started my project on VB, stating it was a Database application.
Doing that , the project was embedded to my database.mdb file, so now I could see a nice GUI of all my tables.
The thing is that I need to choose the mdb in runtime, using a "File Open" dialog box.
Me.ProductOrdersTableAdapter.Fill(Me.PlugDataSet.ProductOrders)
Me.PORowsTableAdapter.Fill(Me.PlugDataSet.PORows)
Me.PINSerialTableAdapter.Fill(Me.PlugDataSet.PINSerial)
Me.CustomizationTableAdapter.Fill(Me.PlugDataSet.Customization)
Me.FirmwareTableAdapter.Fill(Me.PlugDataSet.Firmware)
- All these (for example) have been added to my form1.vb code. the thing is that PlugDataSet and ProductOrdersBindingSource were all generated inside the project files. All I want to do is change the DB source in runtime.
How can I change the connection string for the mdb file and not affect all my code ?
Thx
-- modified at 12:34 Wednesday 10th May, 2006
|
|
|
|
|
hi all,
There is tabled called "dbo.MarkOne".
There are 20 columns there with a AutoNumber Column(AutoNum)
Now I need to get Auto Number with Minimum Price Grouping DestinationAirport,DepartureAirport,AirLineCode,FareClass Column Details
query is like this.
SELECT MIN(Price),AutoNum AS NEWPRICE FROM dbo.MarkOne
GROUP BY DestinationAirport,DepartureAirport,AirLineCode,FareClass
This returns a Error--
Column 'dbo.MarkOne.AutoNum' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
How do I fix this?.I need to show Auto Number with Minimun Price.
Can anyone please help me
|
|
|
|
|
I don't have your data so I will take a guess without testing:
SELECT
AutoNumber,
MarkOne.Price
FROM
MarkOne
INNER JOIN
(SELECT
DestinationAirport,
DepartureAirport,
AirLineCode,
FareClass,
MIN(Price) AS Price
FROM
dbo.MarkOne
GROUP BY
DestinationAirport,
DepartureAirport,
AirLineCode,
FareClass) gMark
ON(gMark.DestinationAirport = MarkOne.DestinationAirport AND
gMark.DepartureAirport = MarkOne.DepartureAirport AND
gMark.AirLineCode = MarkOne.AirLineCode AND
gMark.FareClass = MarkOne.FareClass AND
gMark.Price = MarkOne.Price)
|
|
|
|
|
Hi
Include AutoNum in the GROUP BY
SELECT MIN(Price),AutoNum AS NEWPRICE FROM dbo.MarkOne
GROUP BY DestinationAirport,DepartureAirport,AirLineCode,FareClass, AutoNum
Chinna Srihari
Tech Lead, Capgemini
|
|
|
|
|
I wan to use xp_cmdshell to copy an sql file on another machine (which has a linked server). I use it like this:
EXEC master.. xp_cmdshell 'copy c:\test\query.sql \\Dell7\test' --Dell7 is the other machine
when i apply this query to copy in the local server, it functions, but for the linked server i always have this error :
-----------
Access is denied.
0 file(s) copied.
NULL
---------------
Some friend say with me
Your sql service account needs permission to create file on dell7.
but i dont know Where permission for my service
And my netWork is Domain. I have Account Administrator
Some body help me
|
|
|
|
|
The copy comand will be run as the user that the SQL Server is running as - If you open up the Task Manager, click on the processes tab and look for sqlservr.exe it will tell you what account it is being run as (if you have the User Name column on)
If this is a Domain account you can give the account permission to write files in the destination.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|