You must Sign In to post a response.
  • Category: .NET

    How i link mssql server and how i insert delete in windows mobile application?

    Hi members,
    How I link mssql2005 and how i insert delete data in c# windows mobile application i just develop small app plz correct the sintax and guide me.


    coding

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Microsoft.Phone.Controls;
    using System.Data;
    namespace PhoneApp2
    {
    public partial class MainPage : PhoneApplicationPage
    {
    SqlConnection con;
    SqlDataAdapter da;
    DataSet ds;
    sqlcommand cc;
    public MainPage()
    {
    InitializeComponent();

    con = new SqlConnection("Data Source=USER-PC;Initial Catalog=ram;Integrated Security=True");
    da = new SqlDataAdapter("select * from dd", con);
    ds = new DataSet();
    da.Fill();
    }

    private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
    {

    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
    con.Open();
    SqlCommand cc = new SqlCommand("insert into dd values('" + textBox1.Text + "','" + textBox2.Text + "',)", con);
    cc.ExecuteNonQuery();
    MessageBox.Show("guest record saved succesfully");

    con.Close();

    }

    private void button2_Click(object sender, RoutedEventArgs e)
    {
    con.Open();
    SqlCommand cc = new SqlCommand("Delete from dd where phone no='" + textBox1.Text.ToString() + "'", con);
    cm.ExecuteNonQuery();
    MessageBox.Show("Guest record deleted succesfully");

    con.Close();


    }
    }
    }

    design


    phone:PhoneApplicationPage
    x:Class="PhoneApp2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
    <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
    <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,120,0,0" Name="textBlock1" Text="phone no" VerticalAlignment="Top" />
    <TextBox Height="72" Margin="141,78,0,0" Name="textBox1" Text="TextBox" VerticalAlignment="Top" TextChanged="textBox1_TextChanged" HorizontalAlignment="Left" Width="280" />
    <TextBox Height="72" HorizontalAlignment="Left" Margin="141,190,0,0" Name="textBox2" Text="TextBox" VerticalAlignment="Top" Width="270" />
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="15,232,0,0" Name="textBlock2" Text="name" VerticalAlignment="Top" />
    <Button Content="Save" Height="72" HorizontalAlignment="Left" Margin="94,299,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />
    <Button Content="Delete" Height="72" HorizontalAlignment="Left" Margin="261,299,0,0" Name="button2" VerticalAlignment="Top" Width="160" Click="button2_Click" />
    <Grid Height="114" HorizontalAlignment="Left" Margin="126,447,0,0" Name="grid1" VerticalAlignment="Top" Width="285" DataContext="{Binding}" />
    </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
    <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
    <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
    <shell:ApplicationBar.MenuItems>
    <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
    <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
    </shell:ApplicationBar.MenuItems>
    </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->


    wds
    blackcaps
    vramesh2019@gmail.com
  • #766290
    I have not tried my own but you can refer below links
    http://bsubramanyamraju.blogspot.in/2015/01/windowsphone-81-sqlite-how-to-store.html
    https://channel9.msdn.com/Shows/Inside+Windows+Phone/Practical-MVVM-For-Windows-Phone
    http://stackoverflow.com/questions/27009402/crud-in-mvvm-in-windows-phone-8
    https://msdn.microsoft.com/en-in/library/windows/apps/ff402529(v=vs.105).aspx

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766305
    Hi,

    Have you got any error while implement the same?

    If yes, please post the error details, so that we can help you better.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #766359
    Hi members,

    I just write a inset delete . which header file i put if i use sq l server i used system.data.sqlclient. which header file i used to link ms sql server in windows phone application? plz help me.

    wds
    blackcapss
    vramesh2019@gmail.


Sign In to post your comments