Tag: ado.net

Using ADO .NET convert datatime from sql Server to DateTime in VB .NET

I have created a Web Service in Visual Studio 2005, using VB .NET language. This Web Service interacts with a database on Sql Server through ADO .NET. Using ADO .NET I get one table with this code conn = New SqlConnection(Utilities.ConnectionString) sqlcmd = New SqlClient.SqlCommand() sqlcmd.Connection = conn sqlcmd.CommandType = CommandType.Text sqlcmd.CommandText = “select * […]

Write Null in Database if the TextBoxes are Empty

All I want to do is to insert Null with the database when the textbox is empty. –ACCOUNT AS BEGIN — SET NOCOUNT ON added to prevent extra result sets from — interfering with SELECT statements. SET NOCOUNT ON; SET IDENTITY_INSERT account ON INSERT INTO dbo.account ( AccntID , managedby , AccountHolder , Description , […]

Error converting data type nvarchar to numeric

I used the following statement for a parameter. comm.Parameters.Add(“@name”, SqlDbType.NVarChar, 50).Value = txtname.Text; Name is a SQL Server nvarchar column but I get this error: Error converting data type nvarchar to numeric. My sql: SqlCommand comm = conn.CreateCommand(); comm.CommandText = “execute addName @name”; comm.Parameters.Add(“@name”, SqlDbType.NVarChar, 50).Value = txtname.Text; conn.Open(); comm.ExecuteNonQuery(); conn.Close(); Can help my to […]

ConnectionString for SQL Server

I have xampp installed in my computer. I am trying to access data with ADO.Net. The connection string I am using is given below: string connectionString = “Server = localhost; Database = magento; User Id = magento; Password = abcd;”; SqlConnection con = new SqlConnection(connectionString); string cmdString = “SELECT date_added,title,description,url FROM adminnotification_inbox”; SqlDataAdapter da = […]

Hierarchy in SQL and ASP.net

I am creating a web page which contains Posts and Comments. When I retrieve the Comments for each Post during the rendering of that Post, however, the retrieval is very slow. My guess is that this is due to opening/closing connections frequently. Regardless, it doesn’t scale well. To fix this, I am considering merging the […]

Delete from table, and return the records which weren't deleted

I have an table at my SQLSERVER(2008R2) called “Clients” , it has ClientID and Address. I’d like to make a query/SP which does the following: Recieves a list of addresses. Deletes the records with these address. Returns a list of the addresses that can’t be deleted(row not found, etc). Returns the number of deleted rows. […]

Creating Dataset Dynamically and passing to ReportViewer

all i did is just create a reportViewer in the form, then i have this code: SqlConnection cn = new SqlConnection(@”Data Source=.\SQLEXPRESS;AttachDbFilename=G:\I.S\C#\billingSystem\Store.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True”); private void Form1_Load() { runRptViewer(); cn.Open(); } private void rptGetDataset() { DataSet ds = new DataSet(); ds.DataSetName = “dsNewDataSet”; SqlDataAdapter da = new SqlDataAdapter(“SELECT * FROM NewBill”, cn); ds.GetXmlSchema(); da.Fill(ds); […]

while passing multiple integer value together getting error

I have a stored procedure like this: ALTER PROCEDURE [dbo].[T_TransactionSummary] @locations integer AS BEGIN ………….. …………. AND (Location_tbl.Locid IN (@locations)) my locid field is integer this locid coming from my listbox.if i select one item 1 locid will come.if i select 2 item 2 locid will come.. I’ve got a ListBox which populates the @locations […]

Insert Records in SQL Server from Oracle C#

I am working on winform application in C# where I have to import some 200,000 records from an Oracle view and dump into SQL Server table. I am not sure how to approach this problem whether i should use datatable to hold all these records and then store it in SQL server Or I have […]

dataTable as parameter to Function

I have SQL SP’s that I use to populate DataTables in VB and those to fill listbox/charts etc in VB form. In VB I am trying to use OOP and thus use classes for variables. In VB I have a function with the code to pull the data using a SP, this function I want […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.