|
I started using ADO.NET to access data from SQL database in my ASP.NET applications, however, those commands I used so far is to talk to an existed database. If I want to create a new database, is there any easy way to do it in ADO or sth. else? Thanks a lot!
|
|
|
|
|
Assuming you are connected to the server as a user that has the rights to create a database (and next some tables)
CREATE DATABASE <database name>; look up in Books Online the syntax for CREATE DATABASE to see all the different settings you can specify. While you're looking that up, look up CREATE TABLE too, because you'll need some tables added in order to do much with that database
James
Sig code stolen from David Wulff
|
|
|
|
|
This is a sql command, and I normally use ADO's object SQLcommand and its method "command.ExecuteNonQuery()" to execute the required sql command in my C# program or ASP.NET c# server code. However, that SQLcommand object requires connection first, which needs to have a existed DB available. So in this case, sqlcommand may not be a good choice to run that creation command. Any ideas any other object I can use in my C# program? Thanks a lot!
|
|
|
|
|
You can connect to SQL server without using a specific database.
If you specify CATALOG in your connection string, remove it; and you should be ok. The account you use to connect to SQL Server (either Windows authentication or username/password authentication) needs to have permissions to create databases.
James
Sig code stolen from David Wulff
|
|
|
|
|
I am using ADO and have the following queries in my database
Query: GetPW
SELECT [PW].[Number], [PW].[Status] FROM PW
WHERE [PW].[id]=CCID;
Query: GetPR
SELECT [PR].[Number], [PR].[Status] FROM PR
WHERE [PR].[id]=CCID;
Query: GetPWPR
PARAMETERS CCID Long;
SELECT *
FROM GetPW LEFT JOIN GetPR ON [GetPW].[Number]=[GetPR].[Number] ORDER BY [GetPW].[Number];
When I execute query "GetPWPR" from within access, It works fine. (ie Prompts for CCID input value and returns records from PR and PW as expected)
However when I execute using ADO::Execute command it fails with the error "IDispatch error #3127" (DB_E_NOTABLE)
Any clues ?
Thanks
|
|
|
|
|
Does anyone know how to programmatically produce the OLEDB connection dialog box so that my application can ask for a database and then get its ConnectionString.
I'm using C#
Thanks,
Dave.
|
|
|
|
|
You must use the Microsoft OLE DB Service Component 1.0 . It's a COM object.
Jason Gerard
|
|
|
|
|
Cheers, I'll have a look.
Dave.
|
|
|
|
|
I have a MS-SQL 2000 db with a timestamp field. What is the best type in c# to use to store the value of a timestamp?
The Doc's suggest that it is an 8 Byte number and that it should be stored in a DateTime. Is this correct?
Thanks
Stephen.
|
|
|
|
|
This is the situation. We have an online SQL server powering a web site, and then another SQL server powering a back-office system. The web site SQL server is online all the time while the back-office SQL server only ever comes online when the users dial up.
When the users dial up we want to synch the two databases to contain identical data. Now while the back-office SQL server was offline the users could have entered in many records as well as many records being recorded on the web site SQL server. Obviously these records have unique IDs and primary keys associated with them, so we need to maintain relationships etc.
Neither is the "central" server so we cannot just replicate one to the other.
Does any body have any pointers as to what the most reliable method is of achieving this? Any links to tutorials, walk throughs, forums etc. on the subject would be much appreciated, ta.
|
|
|
|
|
Maybe I'm not thinking about this correctly, but if you are using SQL Server 7+ can't you use Merge replication. With merge replication you don't need a "master" db. One DB has to be the publisher and others can be subscribers. With merge replication you can enter data in any of the DB's and have it replicated to the others.
|
|
|
|
|
Matt Gullett wrote:
Maybe I'm not thinking about this correctly, but if you are using SQL Server 7+ can't you use Merge replication
No you are thinking about it perfectly well. Merge replication is what I am setting up, but I thought it best to ask you guys if there were better alternatives.
Thanks
|
|
|
|
|
Has anyone ever created a DTS package, then saved it to a .bas file to be used in VB? We are doing that on a project at work where we are having some issues. The DTS script is making a connection to a database and then specifying a flat file as another source. The idea here is to pump the data (160,000 records) over to the database into a table. While this is an extremely efficient method one of our users can not do this. The pump basically fails. No data gets moved at all. I know the connection is established through SSPI however I am not sure what could be going wrong. This may seem vague, but has anyone run into issues like this before?
Nick Parker
If the automobile had followed the same development as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year killing everyone inside.
-Robert Cringely
|
|
|
|
|
I have a DTS package that was failing; but i created a user on the SQL database with just enough permissions and modified the DTS to use that authentication instead of Windows Authentication, it worked.
It could be the Windows login that he is trying to do this from does not have suffcient rights.
I am yet to figure out the problem in the other case.
I do not know whether it would apply to jour scenario. I never created a VB DTS package
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Thomas George wrote:
i created a user on the SQL database with just enough permissions and modified the DTS to use that authentication instead of Windows Authentication, it worked.
Could you show how you switched the authentication to SQL from NT, I'm not sure how I can convert this. I tried to switch it over to an ADODB connection, however it wouldn't take that and we are going to SQL Server.
Set oConnection = goPackage.Connections.New("SQLOLEDB")
oConnection.ConnectionProperties("Integrated Security") = "SSPI"
oConnection.ConnectionProperties("Persist Security Info") = False
oConnection.ConnectionProperties("Initial Catalog") = "[OurTableName]"
oConnection.ConnectionProperties("Data Source") = "[OurServerName]"
oConnection.ConnectionProperties("Application Name") = "DTS Designer"
oConnection.Name = "[OurServerName]"
oConnection.ID = 1
oConnection.Reusable = True
oConnection.ConnectImmediate = False
oConnection.DataSource = "[OurServerName]"
oConnection.ConnectionTimeout = 60
oConnection.Catalog = "Reference"
oConnection.UseTrustedConnection = True
oConnection.UseDSL = False
Nick Parker
If the automobile had followed the same development as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year killing everyone inside.
-Robert Cringely
|
|
|
|
|
Actually, you can dump any DTS out to VB... It's cryptic as hell to read if you have a complex one cause DTS doesn't choose damnes worth a darn. In a cast like yours, I usually embed some kind of logging mechanism into the DTS package to get the returned status codes. And security can be a problem for running stuff, but it's usually only if run manually. The agent running stuff is usually set to go from install to run against any db.
Mark
|
|
|
|
|
Can anyone suggest me the line of codes and the data type of the field through which we can store files in an SQl Server Database through an ODBC Recordset
Samir Sood
|
|
|
|
|
You question is unclear. Please try again. Do you want to save binary data, i.e. "files", in a field in a SQL Server database? As far as the lines of code, you would use an INSERT statement to store new rows and an UPDATE statement to modify existing rows.
|
|
|
|
|
I want to store actual files i.e txt , rtf and doc files in the database .
Please Give the ines of code to insert and update them throgh odbc in MFC.
Samir Sood
|
|
|
|
|
You can store anything into BINARY database fields.
Read/Store the file to/from CLongBinary.
You can use CLongBinary variable in RFX_LongBinary for typed recordset.
Pavel
Sonork 100.15206
|
|
|
|
|
I want to send email from SQL server. Please tell me how? Do tell me complete procedure as how to make SQL server, an email client and what to do next ????
|
|
|
|
|
|
Just like this...
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo.p_SampleDateRangeProc]
@StartDate datetime,
@EndDate datetime
AS
select * from YourTable t (nolock)
where t.DateField >= @StartDate
and t.DateField <= @EndDate
If @@Error <> 0
Return -1
Return 0
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|
|
SELECT Country_Ext_Code FROM Countries_Extensions WHERE (NOT (Country_Ext_Code IN (SELECT country_ext_code FROM rates_phone_zones WHERE Rate_Group_Phone_Code = ?))) doesn't works.
SELECT Country_Ext_Code FROM Countries_Extensions WHERE (NOT (Country_Ext_Code IN (SELECT country_ext_code FROM rates_phone_zones WHERE Rate_Group_Phone_Code = 1))) works fine.
* Note the change "?" x "1"
|
|
|
|
|
What on earth are you trying to achieve with
WHERE Rate_Group_Phone_Code = ?
STL is a religeon. Enquiries to Reverend Christian Graus
|
|
|
|