|
I'm using SQL 2005 Express, and VC#2005 Express. Using a SQLCommand.ExecuteNonQuery() with a CREATE TABLE statement, I can make a table in my database with the columns I need, determined at runtime. I've verified the table is made in the database correctly, via SQL server Management Studio Express. In the process of making the CREATE TABLE statement, I also make the table in my local DataSet, same name, same columns, should be identical, along with a DataAdapter for the table. However, when I try to DataAdapter.Fill() the table, it tells me the table name is invalid, like the table isn't in the database on disk. I've tried setting the MissingSchema property to PassThrough, and then the .Fill() makes a new table, same columns, keys, etc., but the name of the new table is "Table", not the table name I create it with. Any help on this, either the table isn't being made right, or the DataAdapter is screwing up somehow, I can't figure it out.
My CREATE TABLE statement
CREATE TABLE finished (Listing NOT NULL PRIMARY KEY IDENTITY(1000,1),[More data columns, shouldn't be the problem, just data])
The SELECT statement used in DataAdapter
SELECT Listing,[More columns as above] FROM finished
I can post the code if needed
A soft glow comes from the pit in the darkness.
The clicking noise become faster - and louder.
A wind begins to stir up from the pit, as the
creature flexes it's wings, preparing for flight.
You stare into the pit, and hear a voice say
in your mind, "If you survive the encounter,
declare it to the world."
The Code Demon Rises.
|
|
|
|
|
Replying to my own post... In case anyone else has this problem, here's how I figured this out. Simple really. I just needed to add a TableMapping to the DataAdapter, and give it the right names. One line of code fixed a 3 day problem.
myDataAdapter.TableMappings.Add( "Table", myTable.TableName );
Have Fun!
A soft glow comes from the pit in the darkness.
The clicking noise become faster - and louder.
A wind begins to stir up from the pit, as the
creature flexes it's wings, preparing for flight.
You stare into the pit, and hear a voice say
in your mind, "If you survive the encounter,
declare it to the world."
The Code Demon Rises.
|
|
|
|
|
If you really want to be slick and save some work you could create the table as a datatable first then use SqlServer Management Objects to create the table at run time based on your in memory datatable. This only works with Sql2005 and Express2005, but it really save time in the code and verifies that what you have in memory matches with the database. If you are interested:
http://www.codeproject.com/useritems/DataTableToDataBase.asp[^]
Yes, this is one of my articles( currently my only one as I have been swamped) but SMO has become a pet project of mine as I am fascinated by it. Take a look and see if it helps.
Aaron
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
How can we protect our database in Sql Server 2000
|
|
|
|
|
Bachuli wrote: How can we protect our database in Sql Server 2000
There are numerous ways to protect a SQL Server database.
* Provide passwords for the accounts that are permitted to access it.
* Define appropriate permissions on the databases
* Define appropriate permissions on the objects in the databases
* Run the SQL Server service in a restricted account
* Turn off TCP/IP (if access is not required across a network)
* Set up firewalls to prevent the SQL Server's port being exposed outside the corporate LAN
* Install Service Pack 3a or above (which fixes the bug that allowed the Slammer worm to work)
*
*
*
*
There are too many ways to describe in a forum post. You might want to buy a book on SQL Server Security.
|
|
|
|
|
find the difference between 2 given dates in days using case
Revathi Raj
|
|
|
|
|
|
Hi all,
I want to compare my system time with the time in MS Access table. I want to display those records which are greater than the current time(even the seconds not the milli seconds).
Plz any one suggest me the query.
Thanks in advance
bye
Know is Drop, Unknown is Ocean
|
|
|
|
|
please help me with the sql statement to display the information on the gridview according to the selected dates(stating date and ending date)when you click generate info butto
oga
|
|
|
|
|
select * from tblName where Date>=startDate and Date<endDate.
|
|
|
|
|
from txtSdate and txtEdate
oga
|
|
|
|
|
select * from tblName where cast(Date as datetime)>=cast(txtStartdate as datetime)
and cast(date as datetime)<=cast(txtEnddate as datetime)
I assume Date column is also in text format.
|
|
|
|
|
How to provide the password protection in SQL Server 2000
|
|
|
|
|
You would normally do this in your calling code. While there is a password function in SQL Server, it is quite a weak implementation.
In the code that was responsible for managing the user details, you would typically want to encrypt the password and a salt string. If you store the salt in the database, it is a simple matter to compare the user entered password + the salt with the encrypted password stored in the database and compare them to see if they match.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
sir
i want to protect my sqlserver database with password.so that no any one can modify my table containt.
as i used database in my asp.net program.
i want to change it only through program not directly database.
is it possible.
then reply me.
ajeet
|
|
|
|
|
I am trying to update a MS ACCESS table that has a column defined as a datetime type. The update looks like:
string updateSQL = "update Perform " +
" set venueCd = ?, " + " performanceDTTM = ?, " +
" performanceDesc = ?, " +
"lotteryPerformance = ?, " +
" lotteryAsgnComplete = ?, " +
" performHandicapLogic = ?, " +
" maxNumOfCompTks = ?, " +
" maxNumOfAdditionalTks = ?, " +
" costOfEachAddTk = ? " +
" where venueCd = ? and " +
" performanceDTTM = ?";
I am using a OleDbType.Date parm to pass in the value of the date time. The value is correct in the parameter and there is a row that it should find and update. Any help would be appreciated.
Thanks,
Patrick
|
|
|
|
|
Even down to the millisecond? (Just a thought - I've been caught out with that in the past)
|
|
|
|
|
that is a good question. I can view the data in ms access and it does not display sectonds or milliseconds. The value I am passing in is actually read from the row that I am trying to update from a prior select.
Colin, is there anything special I should do since I am working with dates with MS Access?
Patrick
|
|
|
|
|
I changed the where to:
DateValue(performanceDTTM) = DateValue(@oldPerformanceDTTM)
I used the DateValue function. I really do not understand why I had to use it since both the column and the parm were datetime data types.
|
|
|
|
|
I'm making tables at runtime, and adding them to the SQL DB on disk, which is working. Along the way, I'm also making the select string, which from past tries, I know works. When I try to make the command builder, it doesn't build the other SQL commands I need. Any Help on how to use this. I know it should be building the commands the first time Update is called, but it isn't doing so. I had this working once, added some columns to the table, and now it doesn't work. Trouble is, I don't have a backup of the code that worked.
A soft glow comes from the pit in the darkness.
The clicking noise become faster - and louder.
A wind begins to stir up from the pit, as the
creature flexes it's wings, preparing for flight.
You stare into the pit, and hear a voice say
in your mind, "If you survive the encounter,
declare it to the world."
The Code Demon Rises.
|
|
|
|
|
Hi,
Could someone please help me in this simple task.
I have two tables below. I need to set checked="ok" for those products that have no entry in [expiration date] table. Thanks in advance.
I imagine this would be something like this, but it's incorrect:
UPDATE (product as p<br />
INNER JOIN [expiration date] AS ed ON p.id=ed.product_id)<br />
SET checked='ok' WHERE (COUNT(*) FROM [expiration date] = 0)<br />
<br />
product<br />
-------<br />
id<br />
name<br />
checked<br />
<br />
expiration date<br />
---------------<br />
product_id<br />
exp_date<br />
quantity<br />
|
|
|
|
|
Hope this helps U.
Test this with some fake table before U proceed.
update product set
ckecked='ok' where id not in (select product_id from expirationdate)
Regards,
Arun Kumar.A
-- modified at 10:43 Sunday 22nd April, 2007
|
|
|
|
|
Try this:
update p set checked='ok'
from product p
where id in
( select id
from product p2
join expirationdate e on p2.id = e.product_id
group by id
having count(*) = 0)
I guess the question would be if there are records or not, it might be easier to do a left join if there are no records.
So that would be:
update p set checked='ok'
from product p
where id in
( select id
from product p2
left join expirationdate e on p2.id = e.product_id
where e.product_id is null)
Hope that helps.
Ben
|
|
|
|
|
Hello,
I'm using access 2007 as the database for a crystal reports project in vs.net 2005. When i try to preview or view the report, i get the error:
"Failed to open rowset"
Details: ADO Error Code:0x
Source: Microsoft Jet Database Engine
Description: Syntax error in JOIN Operation
SQL State: 3000
Native Error.
I tried to analyze the SQL Query...but i dunt understand wat hte problem is:
SELECT `tblDesc`.`North`, `tblDesc`.`South`, `tblDesc`.`East`, `tblDesc`.`West`, `tblDoc`.`Loan_Applicant`, `tblDoc`.`SubType`, `tblDoc`.`Plot_No`, `tblDoc`.`BR_Count`, `tblDoc`.`Family`, `tblDoc`.`Maid`, `tblDoc`.`Study`, `tblDoc`.`Plot_Area`, `tblDoc`.`Zoned`, `tblDoc`.`Tenure`, `tblDoc`.`BUA`, `tblDoc`.`Original_Price`, `tblDoc`.`Reg_Date`, `tblIntro`.`VRN`, `tblIntro`.`RRN`, `tblIntro`.`R_Date`, `tblIntro`.`I_Date`, `tblTitles`.`Title`, `tblValuation`.`Market_Value`, `tblValuation`.`MV_Words`, `tblValuation`.`Replacement_Value`, `tblValuation`.`RV_Words`, `tblValuation`.`Forced_Sale_Value`, `tblValuation`.`FSV_Words`, `tblValuation`.`Valuation_Date`, `tblValuator`.`Name`, `tblPropertyType`.`Property_Type`, `tblReports`.`ReportID`, `tblDesc`.`Topography`, `tblDesc`.`Location`, `tblDesc`.`Access`, `tblDoc`.`Address`, `tblExtra`.`Quality`, `tblExtra`.`Occupancy`, `tblExtra`.`Services`, `tblExtra`.`Comments`
FROM ((`ReportDB`.`dbo`.`tblIntro` `tblIntro` INNER JOIN `ReportDB`.`dbo`.`tblValuator` `tblValuator` ON `tblIntro`.`ValuatorID`=`tblValuator`.`ValuatorID`) INNER JOIN (((`ReportDB`.`dbo`.`tblReports` `tblReports` INNER JOIN `ReportDB`.`dbo`.`tblValuation` `tblValuation` ON `tblReports`.`ValuationID`=`tblValuation`.`ValuationID`) INNER JOIN `ReportDB`.`dbo`.`tblExtra` `tblExtra` ON `tblReports`.`ExtraID`=`tblExtra`.`ExtraID`) INNER JOIN ((`ReportDB`.`dbo`.`tblDoc` `tblDoc` INNER JOIN `ReportDB`.`dbo`.`tblPropertyType` `tblPropertyType` ON `tblDoc`.`PropertyID`=`tblPropertyType`.`PropertyID`) INNER JOIN `ReportDB`.`dbo`.`tblTitles` `tblTitles` ON `tblDoc`.`TitleID`=`tblTitles`.`TitleID`) ON `tblReports`.`DocID`=`tblDoc`.`DocID`) ON `tblIntro`.`IntroID`=`tblReports`.`IntroID`) INNER JOIN `ReportDB`.`dbo`.`tblDesc` `tblDesc` ON `tblReports`.`DescID`=`tblDesc`.`DescID`
WHERE `tblReports`.`ReportID`=1
any help will be greatly appreciated...
|
|
|
|
|
for ex. after INNER JOIN `ReportDB`.`dbo`.`tblReports` `tblReports`, again another INNER JOIN is starting.
Hope this is the problem
inner join usage is
INNER JOIN ON <condition>
where as in some of the inner joins of your query the "ON <condition>" is missing after <tablename>
Regards
KP
|
|
|
|
|